home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_html2ps.idb / usr / freeware / bin / html2ps.z / html2ps (.txt)
Microsoft Windows Help File Content  |  1999-01-26  |  125KB  |  4,079 lines

  1. : # Use perl
  2. eval 'exec perl -S $0 "$@"'
  3.   if $running_under_some_shell;
  4. # This is html2ps version 1.0 beta1, an HTML-to-PostScript converter.
  5. #   Copyright (C) 1995-1997 Jan Karrman.
  6. #   This program is free software; you can redistribute it and/or modify
  7. #   it under the terms of the GNU General Public License as published by
  8. #   the Free Software Foundation; either version 2 of the License, or
  9. #   (at your option) any later version.
  10. #   This program is distributed in the hope that it will be useful,
  11. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #   GNU General Public License for more details.
  14. #   You should have received a copy of the GNU General Public License
  15. #   along with this program; if not, write to the Free Software
  16. #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. # Author: Jan Karrman, Dept. of Scientific Computing, Uppsala University,
  18. #         Sweden, e-mail: jan@tdb.uu.se.
  19. # Set the name of the global configuration file. See the installation notes
  20. # and manual page for more details on configuration files.
  21. $globrc='/usr/freeware/lib/html2ps/html2psrc';
  22. $conf=<<'EOR';
  23. @html2ps {
  24.   package {
  25.     PerlMagick: 0;
  26.     ImageMagick: 0;
  27.     pbmplus: 0;
  28.     netpbm: 0;
  29.     djpeg: 0;
  30.     Ghostscript: 0;
  31.     TeX: 0;
  32.     dvips: 0;
  33.     libwww-perl: 0;
  34.     jfriedl: 0;
  35.     geturl: "";
  36.     check: "";
  37.     path: "";
  38.   paper {
  39.     type: A4;
  40.     height: "";
  41.     width: "";
  42.   option {
  43.     twoup: 0;
  44.     base: "";
  45.     check: 0;
  46.     toc: "";
  47.     debug: 0;
  48.     DSC: 0;
  49.     encoding: "ISO-8859-1";
  50.     rcfile: "";
  51.     frame: 0;
  52.     grayscale: 0;
  53.     help: 0;
  54.     hyphenate: 0;
  55.     scaleimage: 1;
  56.     language: "";
  57.     landscape: 0;
  58.     scalemath: 1;
  59.     number: 0;
  60.     startno: "";
  61.     output: "";
  62.     original: 0;
  63.     rootdir: "";
  64.     xref: 0;
  65.     scaledoc: 1;
  66.     style: "";
  67.     text: 0;
  68.     underline: 0;
  69.     colour: 0;
  70.     version: 0;
  71.     web: "";
  72.     duplex: "";
  73.   margin {
  74.     left: 2.5cm;
  75.     right: 2.5cm;
  76.     top: 3cm;
  77.     bottom: 3cm;
  78.     middle: 2cm;
  79.   xref {
  80.     text: "[p $N]";
  81.     passes: 1;
  82.   quote {
  83.     en {
  84.       open: "“";
  85.       close: "”";
  86.       open2: "`";
  87.       close2: "'";
  88.     }
  89.     sv {
  90.       open: "”";
  91.       close: "”";
  92.       open2: "'";
  93.       close2: "'";
  94.     }
  95.     da {
  96.       open: "»";
  97.       close: "«";
  98.     }
  99.     no {
  100.       open: "«";
  101.       close: "»";
  102.     }
  103.     fr {
  104.       open: "« ";
  105.       close: " »";
  106.     }
  107.     de {
  108.       open: "„";
  109.       close: "“";
  110.       open2: "‚";
  111.       close2: "`";
  112.     }
  113.     fi: sv;
  114.     es: en;
  115.     it: no;
  116.   toc {
  117.     heading: "<H1>$T</H1>
  118.               <H2>Table of Contents</H2>";
  119.     level: 6;
  120.     indent: 1em;
  121.     extrapage: 1;
  122.   font {
  123.     times {
  124.       names: "Times-Roman
  125.               Times-Italic
  126.               Times-Bold
  127.               Times-BoldItalic";
  128.     }
  129.     new-century-schoolbook {
  130.       names: "NewCenturySchlbk-Roman
  131.               NewCenturySchlbk-Italic
  132.               NewCenturySchlbk-Bold
  133.               NewCenturySchlbk-BoldItalic";
  134.     }
  135.     helvetica {
  136.       names: "Helvetica
  137.               Helvetica-Oblique
  138.               Helvetica-Bold
  139.               Helvetica-BoldOblique";
  140.     }
  141.     helvetica-narrow {
  142.       names: "Helvetica-Narrow
  143.               Helvetica-Narrow-Oblique
  144.               Helvetica-Narrow-Bold
  145.               Helvetica-Narrow-BoldOblique";
  146.     }
  147.     palatino {
  148.       names: "Palatino-Roman
  149.               Palatino-Italic
  150.               Palatino-Bold
  151.               Palatino-BoldItalic";
  152.     }
  153.     avantgarde {
  154.       names: "AvantGarde-Book
  155.               AvantGarde-BookOblique
  156.               AvantGarde-Demi
  157.               AvantGarde-DemiOblique";
  158.     }
  159.     bookman {
  160.       names: "Bookman-Light
  161.               Bookman-LightItalic
  162.               Bookman-Demi
  163.               Bookman-DemiItalic";
  164.     }
  165.     courier {
  166.       names: "Courier
  167.               Courier-Oblique
  168.               Courier-Bold
  169.               Courier-BoldOblique";
  170.     }
  171.   hyphenation {
  172.     min: 8;
  173.     start: 4;
  174.     end: 3;
  175.     en {
  176.       file: "";
  177.       extfile: "";
  178.     }
  179.   header {
  180.     left: "";
  181.     center: "";
  182.     right: "";
  183.     odd-left: "";
  184.     odd-center: "";
  185.     odd-right: "";
  186.     even-left: "";
  187.     even-center: "";
  188.     even-right: "";
  189.     font-family: Helvetica;
  190.     font-size: 8pt;
  191.     font-style: normal;
  192.     font-weight: normal;
  193.     color: black;
  194.     alternate: 1;
  195.   footer {
  196.     left: "";
  197.     center: "";
  198.     right: "";
  199.     odd-left: "";
  200.     odd-center: "";
  201.     odd-right: "";
  202.     even-left: "";
  203.     even-center: "";
  204.     even-right: "";
  205.     font-family: Helvetica;
  206.     font-size: 8pt;
  207.     font-style: normal;
  208.     font-weight: normal;
  209.     color: black;
  210.     alternate: 1;
  211.   frame {
  212.     width: 0.6pt;
  213.     margin: 0.5cm;
  214.     color: black;
  215.   justify {
  216.     word: 15pt;
  217.     letter: 0pt;
  218.   draft {
  219.     text: DRAFT;
  220.     print: "";
  221.     dir: 0;
  222.     font-family: Helvetica;
  223.     font-style: normal;
  224.     font-weight: bold;
  225.     color: F0F0F0;
  226.   colour {
  227.     black: 000000;
  228.     green: 008000;
  229.     silver: C0C0C0;
  230.     lime: 00FF00;
  231.     gray: 808080;
  232.     olive: 808000;
  233.     white: FFFFFF;
  234.     yellow: FFFF00;
  235.     maroon: 800000;
  236.     navy: 000080;
  237.     red: FF0000;
  238.     blue: 0000FF;
  239.     purple: 800080;
  240.     teal: 008080;
  241.     fuchsia: FF00FF;
  242.     aqua: 00FFFF;
  243.   html2psrc: "$HOME/.html2psrc";
  244.   imgalt: "[IMAGE]";
  245.   datefmt: "%e %b %Y  %R";
  246.   locale: "";
  247.   doc-sep: "<!--NewPage-->";
  248.   ball-radius: 0.25em;
  249.   numbstyle: 0;
  250.   showurl: 0;
  251.   seq-number: 0;
  252.   forms: 1;
  253.   textarea-data: 1;
  254.   page-break: 1;
  255.   expand-acronyms: 0;
  256.   collapse-br: 1;
  257.   spoof: "";
  258. BODY {
  259.   font-family: Times;
  260.   font-size: 11pt;
  261.   text-align: left;
  262.   background: white;
  263. H1, H2, H3, H4, H5, H6 {
  264.   font-weight: bold;
  265.   margin-top: 0.8em;
  266.   margin-bottom: 0.5em;
  267. H1 { font-size: 19pt }
  268. H2 { font-size: 17pt }
  269. H3 { font-size: 15pt }
  270. H4 { font-size: 13pt }
  271. H5 { font-size: 12pt }
  272. H6 { font-size: 11pt }
  273. P, OL, UL, DL, BLOCKQUOTE, PRE {
  274.   margin-top: 1em;
  275.   margin-bottom: 1em;
  276.   line-height: 1.2em;
  277.   text-indent: 0;
  278. OL, UL, DD { margin-left: 2em }
  279. TT, KBD, PRE { font-family: Courier }
  280. PRE { font-size: 9pt }
  281. BLOCKQUOTE {
  282.   margin-left: 1em;
  283.   margin-right: 1em;
  284. ADDRESS {
  285.   margin-top: 0.5em;
  286.   margin-bottom: 0.5em;
  287. TABLE {
  288.   margin-top: 1.3em;
  289.   margin-bottom: 1em;
  290. DEL { text-decoration: line-through }
  291. A:link, HR { color: black }
  292. require POSIX;
  293. %extend=('quote',1, 'font',1, 'colour',1, 'hyphenation',1);
  294. %fal=("serif","times", "sans_serif","helvetica", "monospace","courier");
  295. @fo=("p","pre","h1","h2","h3","h4","h5","h6","i","b","tt","kbd","cite","samp",
  296.  "address","blockquote","ol","ul","dl","dt","dd","table","header","footer");
  297. %quote=('','en');
  298. %valid=('font',1, 'font_files',1);
  299. %cm=('cm',1, 'mm',0.1, 'in',2.54, 'pt',2.54/72, 'pc',2.54/6);
  300. %pt=('cm',72/2.54, 'mm',72/25.4, 'in',72, 'pt',1, 'pc',12);
  301. %space=('thinsp',6, '#8201',6, 'ensp',2, '#8194',2, 'emsp',1, '#8195',1);
  302. $space=join('|',keys %space);
  303. %vars=("T","Ti", "N","Pn", "U","UR", "H","h", "A","Au");
  304. %height=("letter",27.9, "legal",35.6, "arche",121.9, "archd",91.4, "archc",61,
  305.  "archb",45.7, "archa",30.5, "flsa",33, "flse",33, "halfletter",21.6,
  306.  "11x17",43.2, "ledger",27.9);
  307. %width=("letter",21.6, "legal",21.6, "arche",91.4, "archd",61, "archc",45.7,
  308.  "archb",30.5, "archa",22.9, "flsa",21.6, "flse",21.6, "halfletter",14,
  309.  "11x17",27.9, "ledger",43.2);
  310. $version="html2ps version 1.0 beta1";
  311. $opts="2|b:|c|C:|d|D|e:|f:|F|g|h|H|i:|l:|L|m:|n|N:|o:|O|r:|R|s:|S:|T|u|U|v|W:|"
  312.  ."x:";
  313. %optalias=( 'twoup','2', 'base','b', 'check','c', 'toc','C', 'debug','d',
  314.  'DSC','D', 'encoding','e', 'rcfile','f', 'frame','F', 'grayscale','g',
  315.  'help','h', 'hyphenate','H', 'scaleimage','i', 'language','l',
  316.  'landscape','L', 'scalemath','m', 'number','n', 'startno','N', 'output','o',
  317.  'original','O', 'rootdir','r', 'xref','R', 'scaledoc','s', 'style','S',
  318.  'text','T', 'underline','u', 'colour','U', 'version','v', 'web','W',
  319.  'duplex','x');
  320. %type=( 'paper,height',2, 'paper,width',2, 'option,i',3, 'option,m',3,
  321.  'option,N',4, 'option,s',3, 'option,x',4, 'xref,passes',4, 'draft,print',5);
  322. $usage=<<EOU;
  323. Usage:
  324.  html2ps [-2cdDFghHLnORTuUv] [-b URL] [-C string] [-e encoding]
  325.   [-f file[:file[:...]]] [-i num] [-l lang] [-m num] [-N num] [-o file]
  326.   [-r path] [-s num] [-S string] [-W string] [-x num]
  327.   [file|URL [file|URL [...]]]
  328. $args="@ARGV";
  329. &Getopts($opts) || die $usage;
  330. if($opt_d) {
  331.   open(DBG,">html2ps.dbg") || die "Error opening debug file: html2ps.dbg\n";
  332.   print DBG "***** $version\n***** Command: $0 $args\n***** Perl: $]\n";
  333.   print DBG "***** HTML2PSPATH=$ENV{'HTML2PSPATH'}\n";
  334. undef $/;
  335. $user=0;
  336. $V='(-?\d+\.?\d*|-?\d*\.?\d+)';
  337. &getconf($conf);
  338. for(@fo,"draft") {
  339.   eval "\$deffnt{'$_'}=defined \$$_\{'font-family'\}?"
  340.       ."\$$_\{'font-family'\}:\$body{'font-family'}";
  341. $user=1;
  342. if(open(RC,$globrc)) {
  343.   $conf=<RC>;
  344.   print DBG "***** Global file $globrc:\n$conf" if($opt_d);
  345.   &getconf($conf);
  346.   close RC;
  347. } else {
  348.   &dbg("Warning: cannot open the global resource file: $globrc\n") if($globrc);
  349. $html2psrc=~s/^(~|\$HOME)/$ENV{"HOME"}/;
  350. $prc=$html2psrc;
  351. if($opt_f) {
  352.   ($prc=$opt_f)=~s/^:/$html2psrc:/;
  353.   $prc=~s/:$/:$html2psrc/;
  354.   $prc=~s/::/:$html2psrc:/;
  355. $cwd=POSIX::getcwd();
  356. opendir(DIR,$cwd);
  357. @local=readdir DIR;
  358. closedir DIR;
  359. $globrc=~/html2psrc/;
  360. $gdir=$`;
  361. $hpath=$ENV{"HTML2PSPATH"}?$ENV{"HTML2PSPATH"}:".:";
  362. $hpath=~s/^:/$gdir:/;
  363. $hpath=~s/:$/:$gdir/;
  364. $hpath=~s/::/:$gdir:/;
  365. $cur=$hpath=~s/(^|:)\.($|:)/$1$cwd$2/;
  366. @hpath=split(/:/,$hpath);
  367. for(@hpath) {
  368.   if(opendir(DIR,$_)) {
  369.     @files=readdir DIR;
  370.     $files{$_}=" @files ";
  371.     closedir DIR;
  372. @rc=split(/:/,$prc);
  373. for $rc (@rc) {
  374.   $found=0;
  375.   S:for $dir (@hpath) {
  376.     if(-r $rc && !grep(/^$rc$/,@local) || $files{$dir}=~/ $rc /) {
  377.       chdir $dir if($files{$dir}=~/ $rc /);
  378.       if(open(RC,$rc)) {
  379.         $conf=<RC>;
  380.         print DBG "***** Personal file $rc:\n$conf" if($opt_d);
  381.         &getconf($conf);
  382.         close RC;
  383.         $found=1;
  384.       }
  385.       last S;
  386.     }
  387.   &dbg("Error opening resource file: $rc\n") if($opt_f && !$found);
  388. chdir $cwd;
  389. $user=2;
  390. &getconf($opt_S) if($opt_S);
  391. print DBG "*****\n" if($opt_d);
  392. require Image::Magick if($package{'PerlMagick'});
  393. $geturl=$package{'geturl'};
  394. $ulanch="f";
  395. $f=72/2.54;
  396. $giftopm="giftopnm" if($package{'netpbm'});
  397. $giftopm="giftoppm" if($package{'pbmplus'});
  398. for(keys %option){eval "\$opt_$_='$option{$_}' if(!defined \$opt_$_)"};
  399. ($scr=POSIX::tmpnam())=~/\w+$/;
  400. $tempdir=$`;
  401. die $usage if $opt_h;
  402. &dbg("$version\n") if ($opt_v||$opt_d);
  403. for ('left','right','top','bottom') {
  404.   $body{"margin-$_"}=$margin{$_} if(!defined $body{"margin-$_"});
  405. if($opt_u) {$ulanch="t"};
  406. if(defined $opt_x && $opt_x!~/^[0-2]$/) {
  407.   die "Illegal duplex value: $opt_x\n";
  408. $V='(-?\d+\.?\d*|-?\d*\.?\d+)';
  409. for $o ($opt_s,$opt_i,$opt_m,$opt_N) {
  410.   die "Non numeric: $o\n" if(defined($o) && $o!~/^$V$/);
  411. $twoup=$opt_2?"t":"f";
  412. $xp=$toc{'extrapage'}?"t":"f";
  413. die "Invalid option: -W $opt_W\n" if($opt_W!~/^[abflprsL\d]*$/);
  414. $tocdoc=$opt_C=~/[ft]/;
  415. if($tocdoc && !defined $opt_W) {$opt_W=4};
  416. $mult=$#ARGV>0 || $opt_W;
  417. $maxlev=$opt_W=~/(\d+)/?$1:4;
  418. $link=$opt_W=~/l/;
  419. $local=$opt_W=~/s/;
  420. $rel=$opt_W=~/r/;
  421. $below=$opt_W=~/b/;
  422. $layer=$opt_W=~/L/;
  423. $prompt=$opt_W=~/p/;
  424. if($opt_C && $opt_C!~/^(b?[ft]|[ft]b?|b?h|hb?)$/)
  425.   {die "Invalid option: -C $opt_C\n"};
  426. $tc=$opt_C?"t":"f";
  427. $rev=$opt_C=~/t/;
  428. $first=$opt_C=~/b/ || $opt_R;
  429. $th=$tocdoc?"f":"t";
  430. $oeh=0;
  431. $oef=0;
  432. @now=localtime;
  433. POSIX::setlocale(&POSIX::LC_TIME,$locale);
  434. $R='(\s*>|[^a-zA-Z0-9>][^>]*>)';
  435. $S='([\w.:/%-]+)|"([^"]*)"|\'([^\']*)\'';
  436. $X='[\da-fA-F]';
  437. $IM='(gif|jpeg|jpg|png|xbm|xpm|ps|eps)';
  438. for('odd-left','odd-center','odd-right','even-left','even-center','even-right')
  439.   $oeh=1 if defined $header{$_};
  440.   $oef=1 if defined $footer{$_};
  441. for $a ('left','center','right') {
  442.   if(defined $header{"odd-$a"} || defined $header{"even-$a"}) {
  443.     $oeh=1;
  444.   if(defined $footer{"odd-$a"} || defined $footer{"even-$a"}) {
  445.     $oef=1;
  446.   for('','odd-','even-') {
  447.     $apa=$header{$_.$a};
  448.     $numb=1 if($apa=~/(^|[^\$])\$N/);
  449.     $header{$_.$a}="($apa)";
  450.     $apa=$footer{$_.$a};
  451.     $numb=1 if($apa=~/(^|[^\$])\$N/);
  452.     $footer{$_.$a}="($apa)";
  453.     &varsub($header{$_.$a},$footer{$_.$a});
  454. if($oeh) {
  455.   $yz="/YY [[{$header{'odd-left'}}{$header{'even-left'}}]"
  456.      ."[{$header{'odd-right'}}{$header{'even-right'}}]"
  457.      ."[{$header{'odd-center'}}{$header{'even-center'}}]] D\n";
  458. } else {
  459.   $ind=$header{'alternate'};
  460.   $yz="/YY [[{$header{'left'}}$ind][{$header{'right'}}".(1-$ind)
  461.      ."][{$header{'center'}}2]] D\n";
  462. if($oef) {
  463.   $yz.="/ZZ [[{$footer{'odd-left'}}{$footer{'even-left'}}]"
  464.       ."[{$footer{'odd-right'}}{$footer{'even-right'}}]"
  465.       ."[{$footer{'odd-center'}}{$footer{'even-center'}}]] D";
  466. } else {
  467.   $ind=$footer{'alternate'};
  468.   $yz.="/ZZ [[{$footer{'left'}}$ind][{$footer{'right'}}".(1-$ind)
  469.       ."][{$footer{'center'}}2]] D";
  470. $number=$opt_n || !$numb && ($opt_C || $opt_N || $opt_R)?"t":"f";
  471. for ($imgalt,$xref{'text'},$toc{'heading'},$draft{'text'}) {&spec($_)};
  472. for ($paper{'height'},$paper{'width'},$body{'margin-left'},
  473.      $body{'margin-right'},$body{'margin-top'},$body{'margin-bottom'},
  474.      $margin{'middle'},$frame{'margin'}) {
  475.   &getval($_,1);
  476. $opt_s*=0.65 if($opt_2 && $opt_L);
  477. $opt_N=1 if(!defined $opt_N);
  478. $opt_N=int($opt_N-1);
  479. $mm=int($margin{'middle'}*$f);
  480. $is=0.8*$opt_i;
  481. $msc=1/$opt_s;
  482. $mag=1200*$opt_m*$opt_s;
  483. $xref=$opt_R?"t":"f";
  484. $xref{'text'}=~s/\$N/) WB pN WB (/g;
  485. $d=int($f*$frame{'margin'});
  486. $ml=$body{'margin-left'};
  487. $mr=$body{'margin-right'};
  488. $mt=$body{'margin-top'};
  489. $mb=$body{'margin-bottom'};
  490. for (0..10) {
  491.   $temp=2**(-$_/2);
  492.   $width{"a$_"}=int($temp*2**(-1/4)*1000+.5)/10;
  493.   $height{"a$_"}=int($temp*2**(1/4)*1000+.5)/10;
  494.   $width{"b$_"}=int($temp*1000+.5)/10;
  495.   $height{"b$_"}=int($temp*2**(1/2)*1000+.5)/10;
  496. if($width{"\L$paper{'type'}"}) {
  497.   $paper{'height'}=$height{"\L$paper{'type'}"} if(!defined $paper{'height'});
  498.   $paper{'width'}=$width{"\L$paper{'type'}"} if(!defined $paper{'width'});
  499. } elsif($paper{'type'}) {
  500.   &dbg("Unknown paper type: $paper{'type'}\n");
  501. if($opt_L) {
  502.   $width=$paper{'height'}-$ml-$mr;
  503.   $hight=$paper{'width'}-$mt-$mb;
  504.   $xc=int($mt*$f+.5);
  505.   $yc=int($ml*$f+.5);
  506.   $rot=" 90 rotate";
  507. } else {
  508.   $width=$paper{'width'}-$ml-$mr;
  509.   $hight=$paper{'height'}-$mt-$mb;
  510.   $xc=int($ml*$f+.5);
  511.   $yc=int(($paper{'height'}-$mt)*$f+.5);
  512.   $rot="";
  513. $width=($width-$margin{'middle'})/2 if($opt_2);
  514. $w=int($width*$f);
  515. $l=int($hight*$f);
  516. $pag=int($paper{'height'}*72/2.54+.5);
  517. $fe=$opt_F?"t":"f";
  518. $xr=int($w/$opt_s+.5)+$d;
  519. $yb=-int($l/$opt_s+.5)-$d;
  520. $cf=$opt_U?"t":"f";
  521. $rm=$numbstyle?"t":"f";
  522. $pa=$showurl?"t":"f";
  523. $nh=$seq_number?"t":"f";
  524. $ea=$expand_acronyms?"t":"f";
  525. $latin1=$opt_e=~/ISO-8859-1/i;
  526. $lt=$del{'text-decoration'}=~/^line-through$/i?"SE":"WB";
  527. if(!$opt_x && defined $opt_x) {
  528.   $dupl="[{false statusdict/setduplexmode get exec} stopped cleartomark";
  529. if($opt_x) {
  530.   $dupl="[{true statusdict/setduplexmode get exec} stopped cleartomark";
  531. if($opt_x==2) {
  532.   $dupl.="\n[{true statusdict/settumble get exec} stopped cleartomark";
  533. %head=("html",1, "head",1, "title",1, "base",1, "meta",1, "link",1, "style",1,
  534.  "script",1, "isindex",1);
  535. %algn=("left",1, "center",2, "right",3, "justify",4, "char",5);
  536. %f=("void",1, "above",2, "below",3, "hsides",4, "lhs",5, "rhs",6, "vsides",7,
  537.     "box",8, "border",9);
  538. %r=("none",1, "groups",2, "rows",3, "cols",4, "all",5);
  539. %v=("top",1, "middle",2, "bottom",3, "baseline",4);
  540. %it=("radio",0, "checkbox",1, "text",2, "password",2, "image",3);
  541. %ssy=(200,"\\", 201, "(", 202, ")");
  542. %lity=("I",0, "i",1, "A",2, "a",3, "1",4, "disc",5, "square",6, "circle",7);
  543. $ltr=join('|',keys %lity);
  544. %tex=('`a',"\340", '\^a',"\342", '`e',"\350", '`e',"\350", 'c\{c\}',"\347",
  545.       "'e","\351", '\^e',"\352", '"e',"\353", '\^i',"\356", '"i',"\357",
  546.       '\^o',"\364", '`u',"\371", '\^u',"\373", '"u',"\374", '"y',"\377",
  547.       'aa',"\345", '"a',"\344", '"o',"\366", 'ae',"\346", 'oe',"\225");
  548. @hind=(0,0,0,0,0,0);
  549. $ltrs='A-Za-z\222-\226\300-\377';
  550. %ent=(
  551. "lsquo|#8216",96,
  552. "rsquo|#8217",39,
  553. "circ|#710",141,
  554. "tilde|#732",142,
  555. "permil|#8240",143,
  556. "dagger|#8224",144,
  557. "Dagger|#8225",145,
  558. "Yuml|#376",146,
  559. "scaron|#353",147,
  560. "Scaron|#352",148,
  561. "oelig|#339",149,
  562. "OElig|#338",150,
  563. "lsaquo|#8249",151,
  564. "rsaquo|#8250",152,
  565. "sbquo|#8218",153,
  566. "bdquo|#8222",154,
  567. "ldquo|#8220",155,
  568. "rdquo|#8221",156,
  569. "ndash|#8211",157,
  570. "mdash|#8212",158,
  571. "trade|#8482",159,
  572. "nbsp",160,
  573. "iexcl",161,
  574. "cent",162,
  575. "pound",163,
  576. "curren",164,
  577. "yen",165,
  578. "brvbar",166,
  579. "sect",167,
  580. "uml",168,
  581. "copy",169,
  582. "ordf",170,
  583. "laquo",171,
  584. "not",172,
  585. "reg",174,
  586. "macr",175,
  587. "deg",176,
  588. "plusmn",177,
  589. "sup2",178,
  590. "sup3",179,
  591. "acute",180,
  592. "micro",181,
  593. "para",182,
  594. "middot",183,
  595. "cedil",184,
  596. "sup1",185,
  597. "ordm",186,
  598. "raquo",187,
  599. "frac14",188,
  600. "frac12",189,
  601. "frac34",190,
  602. "iquest",191,
  603. "Agrave",192,
  604. "Aacute",193,
  605. "Acirc",194,
  606. "Atilde",195,
  607. "Auml",196,
  608. "Aring",197,
  609. "AElig",198,
  610. "Ccedil",199,
  611. "Egrave",200,
  612. "Eacute",201,
  613. "Ecirc",202,
  614. "Euml",203,
  615. "Igrave",204,
  616. "Iacute",205,
  617. "Icirc",206,
  618. "Iuml",207,
  619. "ETH",208,
  620. "Ntilde",209,
  621. "Ograve",210,
  622. "Oacute",211,
  623. "Ocirc",212,
  624. "Otilde",213,
  625. "Ouml",214,
  626. "times",215,
  627. "Oslash",216,
  628. "Ugrave",217,
  629. "Uacute",218,
  630. "Ucirc",219,
  631. "Uuml",220,
  632. "Yacute",221,
  633. "THORN",222,
  634. "szlig",223,
  635. "agrave",224,
  636. "aacute",225,
  637. "acirc",226,
  638. "atilde",227,
  639. "auml",228,
  640. "aring",229,
  641. "aelig",230,
  642. "ccedil",231,
  643. "egrave",232,
  644. "eacute",233,
  645. "ecirc",234,
  646. "euml",235,
  647. "igrave",236,
  648. "iacute",237,
  649. "icirc",238,
  650. "iuml",239,
  651. "eth",240,
  652. "ntilde",241,
  653. "ograve",242,
  654. "oacute",243,
  655. "ocirc",244,
  656. "otilde",245,
  657. "ouml",246,
  658. "divide",247,
  659. "oslash",248,
  660. "ugrave",249,
  661. "uacute",250,
  662. "ucirc",251,
  663. "uuml",252,
  664. "yacute",253,
  665. "thorn",254,
  666. "yuml",255);
  667. %symb=(
  668. "alpha|#945",141,
  669. "beta|#946",142,
  670. "gamma|#947",147,
  671. "delta|#948",144,
  672. "epsilon|#949",145,
  673. "zeta|#950",172,
  674. "eta|#951",150,
  675. "theta|#952",161,
  676. "thetasym|#977",112,
  677. "iota|#953",151,
  678. "kappa|#954",153,
  679. "lambda|#955",154,
  680. "mu|#956",155,
  681. "nu|#957",156,
  682. "xi|#958",170,
  683. "pi|#960",160,
  684. "piv|#982",166,
  685. "omicron|#959",157,
  686. "rho|#961",162,
  687. "sigma|#963",163,
  688. "sigmaf|#962",126,
  689. "tau|#964",164,
  690. "upsilon|#965",165,
  691. "upsih|#978",241,
  692. "phi|#966",146,
  693. "phiv",152,
  694. "chi|#967",143,
  695. "psi|#968",171,
  696. "omega|#969",167,
  697. "Alpha|#913",101,
  698. "Beta|#914",102,
  699. "Gamma|#915",107,
  700. "Delta|#916",104,
  701. "Epsilon|#917",105,
  702. "Zeta|#918",132,
  703. "Eta|#919",110,
  704. "Theta|#920",121,
  705. "Iota|#921",111,
  706. "Kappa|#922",113,
  707. "Lambda|#923",114,
  708. "Mu|#924",115,
  709. "Nu|#925",116,
  710. "Xi|#926",130,
  711. "Omicron|#927",117,
  712. "Pi|#928",120,
  713. "Rho|#929",122,
  714. "Sigma|#931",123,
  715. "Tau|#932",124,
  716. "Upsilon|#933",125,
  717. "Phi|#934",106,
  718. "Chi|#935",103,
  719. "Psi|#936",131,
  720. "Omega|#937",127,
  721. "fnof|#402",246,
  722. "perp|#8869",136,
  723. "plusmn|#177",261,
  724. "cdot|#183",327,
  725. "or|#8744",332,
  726. "and|#8743",331,
  727. "le|#8804",243,
  728. "ge|#8805",263,
  729. "equiv|#8801",272,
  730. "cong|#8773",100,
  731. "asymp|#8776",273,
  732. "ne|#8800",271,
  733. "sub|#8834",314,
  734. "sube|#8838",315,
  735. "sup|#8835",311,
  736. "supe|#8839",312,
  737. "isin|#8712",316,
  738. "larr|#8592",254,
  739. "rarr|#8594",256,
  740. "uarr|#8593",255,
  741. "darr|#8595",257,
  742. "harr|#8596",253,
  743. "lArr|#8656",334,
  744. "rArr|#8658",336,
  745. "uArr|#8657",335,
  746. "dArr|#8659",337,
  747. "hArr|#8660",333,
  748. "forall|#8704","042",
  749. "exist|#8707","044",
  750. "infin|#8734",245,
  751. "nabla|#8711",321,
  752. "part|#8706",266,
  753. "hellip|#8230",274,
  754. "int|#8747",362,
  755. "sum|#8721",345,
  756. "prod|#8719",325,
  757. "real|#8476",302,
  758. "image|#8465",301,
  759. "bull|#8226",267,
  760. "prime|#8242",242,
  761. "Prime|#8243",262,
  762. "oline|#8254",140,
  763. "frasl|#8260",244,
  764. "weierp|#8472",303,
  765. "alefsym|#8501",300,
  766. "crarr|#8629",277,
  767. "empty|#8709",306,
  768. "notin|#8713",317,
  769. "ni|#8715","047",
  770. "minus|#8722","055",
  771. "lowast|#8727","052",
  772. "radic|#8730",326,
  773. "prop|#8733",265,
  774. "ang|#8736",320,
  775. "cap|#8745",307,
  776. "cup|#8746",310,
  777. "sim|#8764",176,
  778. "nsub|#8836",313,
  779. "oplus|#8853",305,
  780. "otimes|#8855",304,
  781. "sdot|#8901",327,
  782. "lceil|#8968",351,
  783. "rceil|#8969",371,
  784. "lfloor|#8970",353,
  785. "rfloor|#8971",373,
  786. "lang|#9001",341,
  787. "rang|#9002",361,
  788. "spades|#9824",252,
  789. "clubs|#9827",247,
  790. "hearts|#9829",251,
  791. "diams|#9830",250,
  792. "loz|#9674",340);
  793. $pc=')WB NL NP(';
  794. $nimg=-1;
  795. $nm=-1;
  796. &Subst($doc_sep);
  797. &Subst($toc{'heading'});
  798. $toc{'heading'}=~s/  H\(/ -1 H(/g;
  799. @font=();
  800. @size=();
  801. @styl=();
  802. @alig=();
  803. @colr=();
  804. @topm=();
  805. @botm=();
  806. @lftm=();
  807. @rgtm=();
  808. @z1=();
  809. @z2=();
  810. @z3=();
  811. $nfont=0;
  812. $mi=0;
  813. for (@fo) {&setel($_)};
  814. %arr=%draft;
  815. &fs("draft");
  816. if(!$latin1 && !defined $fontid{"times"}) {
  817.   $fontid{"times"}=$nfont++;
  818.   @docfonts=(@docfonts,split(/\s+/,$font_names{"times"}));
  819. $wind=0;
  820. $wf="t";
  821. if(!$latin1) {
  822.   $wind=$fontid{"times"};
  823.   $wf="f";
  824. for $k (keys %font_files){
  825.   @ff=split(/\s+/,$font_files{$k});
  826.   @fn=split(/\s+/,$font_names{$k});
  827.   for (0..3) {
  828.     if($ff[$_]) {
  829.       $ff{$fn[$_]}=$ff[$_];
  830.     } elsif(!$ff{$fn[$_]}) {
  831.       $ff{$fn[$_]}=$ff[0];
  832.     }
  833.     $fr{$fn[$_]}=$k;
  834. $pta=defined $p{"text-align"}?$p{"text-align"}:$body{"text-align"};
  835. $pal=0;
  836. $pal=1 if($pta=~/^c/i);
  837. $pal=2 if($pta=~/^r/i);
  838. $pal=3 if($pta=~/^j/i);
  839. $bgcol=&col2rgb($body{"background"});
  840. if(!$bgcol) {$bgcol="[16#FF 16#FF 16#FF]"};
  841. if(!$p{"color"}) {$p{"color"}="black"};
  842. $tcol=&col2rgb($p{"color"});
  843. $lcol=&col2rgb($a__link{"color"});
  844. if($lcol) {
  845.   $Lc="/Lc t D\n/Dl $lcol D\n";
  846.   $Lc.=$tcol ne $lcol?"/LX t D":"/LX f D";
  847. } else {
  848.   $Lc="/Lc f D\n/LX f D";
  849. $pcol=&col2rgb($pre{"color"});
  850. if(!$pcol) {$pcol="[0 0 0]"};
  851. $deftbg=&col2rgb($table{"background"});
  852. $hc=&col2rgb($hr{"color"});
  853. if(!$hc) {$hc="[0 0 0]"};
  854. $fcol=&col2rgb($frame{"color"});
  855. if(!$fcol) {$fcol="[0 0 0]"};
  856. for ($p{"font-size"},$pre{"font-size"},$header{"font-size"},$frame{'width'},
  857.  $footer{"font-size"},$justify{'letter'},$justify{'word'}) {
  858.   &getval($_,2);
  859. for ($p{"line-height"},$p{"text-indent"},$p{"margin-top"},$toc{'indent'},
  860.      $ball_radius) {
  861.   &getval($_,0);
  862. $fl="/FL [/".join("\n/",@docfonts)."] D";
  863. for $k (keys %ff) {
  864.   $f=$ff{$k};
  865.   if(defined $fontid{$fr{$k}} && !defined($cont{$f})) {
  866.     open(FONT,$f) || &dbg("Error opening fontfile $f\n");
  867.     ($cont{$f}=<FONT>)=~s/(^|\r?\n|\r)%.*//g;
  868.     close FONT;
  869. $fontdef="";
  870. for (keys %cont) {
  871.   $fontdef.=$cont{$_};
  872. &ent($yz);
  873. &ent($xref{'text'});
  874. &ent($draft{'text'});
  875. $lnum=0;
  876. for (keys %quote_open) {
  877.   $lid{$_}=$lnum++;
  878.   if(!defined $quote_close{$_}) {$quote_close{$_}=$quote_open{$_}};
  879.   if(!defined $quote_open2{$_}) {$quote_open2{$_}=$quote_open{$_}};
  880.   if(!defined $quote_close2{$_}) {$quote_close2{$_}=$quote_close{$_}};
  881.   &ent($quote_open{$_});
  882.   &ent($quote_close{$_});
  883.   &ent($quote_open2{$_});
  884.   &ent($quote_close2{$_});
  885.   push(@qo,$quote_open{$_});
  886.   push(@qc,$quote_close{$_});
  887.   push(@qo2,$quote_open2{$_});
  888.   push(@qc2,$quote_close2{$_});
  889. $qo=join(')(',@qo);
  890. $qc=join(')(',@qc);
  891. $qo2=join(')(',@qo2);
  892. $qc2=join(')(',@qc2);
  893. $hyphenation_file{''}=$hyphenation_file{'en'};
  894. $br=$collapse_br?"f":"t";
  895. $gd=0;
  896. $ddr=defined $draft{'print'};
  897. if($ddr) {
  898.   if($draft{'print'}==0) {
  899.     $draft="f";
  900.   } else {
  901.     $gd=1;
  902.     $draft="t";
  903. $gb=$gs_bug?"t":"f";
  904. for (keys %quote) {$lid{$_}=$lid{$quote{$_}}};
  905. $ENV{'PATH'}.=":$package{'path'}" if($package{'path'});
  906. $delim="%-- End of variable part --";
  907. $cd="/Cd {aload length 2 idiv dup dict begin {D} repeat currentdict end} D";
  908. $P0=<<EOC;
  909. %%Creator: $version
  910. %%EndComments
  911. 2000 dict begin
  912. /d {bind def} bind def
  913. /D {def} d
  914. /t true D
  915. /f false D
  916. /WF $wf D
  917. /WI $wind D
  918. /F $opt_s D
  919. /IW $w F div D
  920. /IL $l F div D
  921. /PS $pag D
  922. /EF [@font] D
  923. /EZ [@size] D
  924. /Ey [@styl] D
  925. /EG [@alig] D
  926. /Tm [@topm] D
  927. /Bm [@botm] D
  928. /Lm [@lftm] D
  929. /Rm [@rgtm] D
  930. /EU [@colr] D
  931. /NO $number D
  932. /Ts EZ 0 get D
  933. /TU $twoup D
  934. /Xp $xp D
  935. /AU $ulanch D
  936. /SN $opt_N D
  937. /Cf $cf D
  938. /Fe $fe D
  939. /TI $toc{'indent'} Ts mul D
  940. /FE {newpath -$d $d M CP BB $xr $d L $xr $yb L CP BB -$d $yb L closepath} D
  941. /LA {TU PM 0 eq and{IW $mm F div add SA{Sf div}if 0 translate}
  942.  {$xc $yc translate$rot F SA{Sf mul}if dup scale
  943.  CS CF FS Cf{CA CL get VC}if /Bb f D}ie 0 0 M TF not Tc or
  944.  {Cf{gsave SA{1 Sf div dup scale}if Cb VC FE fill grestore}if Df{Sd}if}if} D
  945. /Pi $p{"text-indent"} Ts mul D
  946. /SG [$is $opt_i $msc] D
  947. /Ab $justify{'word'} D
  948. /J $justify{'letter'} D
  949. /Tc $tc D
  950. /NH $toc{'level'} D
  951. /Nf $nh D
  952. /Pa $pa D
  953. /LH $p{"line-height"} D
  954. /XR $xref D
  955. /Xr {/pN E D ( $xref{'text'} )WB} D
  956. /Db $bgcol D
  957. /Dt $tcol D
  958. /eA $ea D
  959. /Br $ball_radius D
  960. /IA ($imgalt) D
  961. /DS {/PF f D($doc_sep)pop RC ZF} D
  962. /Gb $gb D
  963. /Mb $br D
  964. /Hc $hc D
  965. /Bl 3 D
  966. /MI -$mi D
  967. /DX ($draft{'text'}) D
  968. /Di $draft{'dir'} D
  969. /FD $fontid{"\L$font"} D
  970. /Dy $styl D
  971. /cD $col D
  972. /FW $frame{'width'} D
  973. /FU $fcol D
  974. /ET {/RM $rm D /A0 $pal D /PN SN D /OU t D /Ou t D /W IW D /LL W D D1
  975.  Ms not TP and{Ip}if /TF f D} D
  976. $dupl
  977. $delim
  978. $reenc=<<EOD;
  979. WF{FL{reencodeISO D}forall}{4 1 FL length 1 sub{FL E get reencodeISO D}for}ie
  980. /Symbol dup dup findfont dup length dict begin
  981.  {1 index /FID ne{D}{pop pop}ie}forall /Encoding [Encoding aload pop]
  982.  dup 128 /therefore put D currentdict end definefont D
  983. $defs=<<EOD;
  984. /reencodeISO {
  985.  dup dup findfont dup length dict begin{1 index /FID ne{D}{pop pop}ie}forall
  986.  /Encoding ISOLatin1Encoding D currentdict end definefont} D
  987. /ISOLatin1Encoding [
  988. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  989. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  990. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  991. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  992. /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright
  993. /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash
  994. /zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon
  995. /less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N
  996. /O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright
  997. /asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m
  998. /n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde
  999. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  1000. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  1001. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  1002. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  1003. /.notdef/space/exclamdown/cent/sterling/currency/yen/brokenbar
  1004. /section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot
  1005. /hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior
  1006. /acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine
  1007. /guillemotright/onequarter/onehalf/threequarters/questiondown
  1008. /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
  1009. /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
  1010. /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
  1011. /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute
  1012. /Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
  1013. /aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
  1014. /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex
  1015. /otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis
  1016. /yacute/thorn/ydieresis
  1017. [128/backslash 129/parenleft 130/parenright 141/circumflex 142/tilde
  1018. 143/perthousand 144/dagger 145/daggerdbl 146/Ydieresis 147/scaron 148/Scaron
  1019. 149/oe 150/OE 151/guilsinglleft 152/guilsinglright 153/quotesinglbase
  1020. 154/quotedblbase 155/quotedblleft 156/quotedblright 157/endash 158/emdash
  1021. 159/trademark]
  1022. aload length 2 idiv 1 1 3 -1 roll{pop ISOLatin1Encoding 3 1 roll put}for
  1023. /colorimage where{pop}{
  1024.  /colorimage {
  1025.   pop pop /Pr E D {/Cv Pr D /Gr Cv length 3 idiv string D 0 1 Gr length 1 sub
  1026.    {Gr E dup /i E 3 mul D Cv i get 0.299 mul Cv i 1 add get 0.587 mul add
  1027.     Cv i 2 add get 0.114 mul add cvi put}for Gr} image} D
  1028. /pdfmark where{pop}{userdict /pdfmark /cleartomark load put}ie
  1029. $P1=<<EOT;
  1030. /EX {EC cvx exec} D
  1031. /DU {} d
  1032. /BB {pop pop}d
  1033. /ie {ifelse} d
  1034. /E {exch} d
  1035. /M {moveto} d
  1036. /R {rmoveto} d
  1037. /L {lineto} d
  1038. /RL {rlineto} d
  1039. /CP {currentpoint} d
  1040. /SW {stringwidth} d
  1041. /GI {getinterval} d
  1042. /PI {putinterval} d
  1043. /Sg {setgray} d
  1044. /LW {setlinewidth} d
  1045. /S {dup () ne OU and{0 Co R AT 3 eq LB and HF not and A1 0 ne A2 0 ne or and
  1046.  {A2 0 32 A1 0 6 -1 roll awidthshow}{show}ie 0 Co neg R}{pop}ie
  1047.  OU PH 3 eq or{/Ms t D}if} D
  1048. /U {OU{gsave CP currentfont /FontInfo get /UnderlinePosition get
  1049.  0 E currentfont /FontMatrix get dtransform E pop add newpath M dup SW pop
  1050.  CJ 0 RL stroke grestore}if} D
  1051. /B {OU Br 0 gt and{CP Ts neg Ts .33 mul R gsave 0 Sg
  1052.  CP newpath Ts Br mul 0 360 arc closepath UI 2 mod 0 eq{stroke}{fill}ie
  1053.  grestore M CP E Ts Br 1 add mul sub E BB /Ms t D}if}D
  1054. /NP {Ms TP not or PA and OU and{TP{OR}if f1{mF k2 /mF E D /YC 0 D}if
  1055.  TP TU not PM 0 eq or and{showpage}if DU Ip TE not{LA}if 0.6 LW
  1056.  /CI 0 D /TP t D /Hs f D /hl 6 D /hL 6 D /HI hi D /Ms f D}if Bs XO BO M} D
  1057. /Np {LE sub CP E pop gt PL 0 eq and{NP}if}D
  1058. /Ip {/PN PN 1 add D /Pn RM{1}{4}ie PN Ns D /PM PN SN sub 2 mod D} D
  1059. /GP {E dup 3 -1 roll get PN 1 add 2 mod get dup type /integertype eq
  1060.  {get 0 get}{E pop}ie}d
  1061. /Fc {dup 2 GP exec SW pop /S1 E D dup 1 GP exec SW pop /S2 E D 0 GP exec SW
  1062.  pop /S3 E D S1 0 gt{S2 2 mul S1 add S3 2 mul S1 add 2 copy lt{E}if pop}{0}ie
  1063.  S2 S3 add 2 copy lt{E}if pop IW .9 mul div dup 1 gt{1 E div}{pop 1}ie}D
  1064. /OR {gsave SA{1 Sf div dup scale}if Fe{Cf{FU VC}if FW LW 1 setlinejoin
  1065.  FE stroke}if /YO {60 F div dup 40 gt{pop 40}if}D /cs CS D /cf CF D /CF 0 D
  1066.  /pf PF D /PF f D /Fn FN D /At AT D /AT 0 D /FN EF Hf 1 add get D Fz Fs FS ZZ
  1067.  Fc Fz mul Fs FS EU Hf 1 add get dup type /arraytype eq Cf and{VC}{pop 0 Sg}ie
  1068.  IW IL neg YO sub M ZZ 1 GP exec dup SW pop neg 0 R Sh 0 IL neg YO sub M
  1069.  ZZ 0 GP exec Sh ZZ 2 GP exec dup SW pop IW E sub 2 div IL neg YO sub M Sh
  1070.  Fz Fs FS NO{/AW IW Pn SW pop sub D AW 2 div IL neg YO sub
  1071.  S1 0 gt S2 AW .45 mul gt or S3 AW .45 mul gt or{Fz 2 mul sub}if M Pn Sh}if
  1072.  EU Hf get dup type /arraytype eq Cf and{VC}{pop 0 Sg}ie
  1073.  YY Fc /FN EF Hf get D Hz mul HS FS IW YO M YY 1 GP exec dup SW pop neg 0 R Sh
  1074.  0 YO M YY 0 GP exec Sh YY 2 GP exec dup SW pop IW E sub 2 div YO M Sh
  1075.  /FN Fn D /AT At D t Pb XO SZ SL get neg R /PF pf D grestore /CF 0 D cs cf FS}D
  1076. /Sh {dup () ne{CP Hz 4 div sub BB show CP CS add BB}{pop}ie}D
  1077. /Pb {/OU E D /Ou OU D /PB t D 0 0 M Ba{/Sa save D /BP t D /Fl t D RC /PL 0 D
  1078.  /PH 0 D /W IW D /LE IL .7 mul D /EO 0 D SI ZF /YA 0 D /BO 0 D /C1 () D
  1079.  BA 0 Ts neg R Bb{Xl Yl Xh Yh}if Bb CP Sa restore M
  1080.  {/Yh E D /Xh E D /Yl E D /Xl E D}if /Fl t D}if
  1081.  BL /OU t D /HM f D /Ou t D /PB f D} D
  1082. /Bs {/BP Ba not D}D
  1083. $defs$fontdef$reenc
  1084. /SF {/CS E D SZ SL CS put FO SL FN put /YI CS LH neg mul D dup ST cvs ( ) join
  1085.  CS ST cvs join C1 E join ( NF ) join /C1 E D CS NF /Wf WF FN 0 gt or D
  1086.  /BW Wf{( ) SW pop}{0}ie D}D
  1087. /NF {/cS E D /cF E D cF 0 ge{FL cF get}{/Symbol}ie
  1088.  findfont cS scalefont setfont} D
  1089. /FS {CF or /CF E D FR SL CF put CF CF 0 ge{FN 4 mul add}if E SF} D
  1090. /PC {SH /BP f D fin not GL not and{NL}if /HM t D /LL LS D} D
  1091. /BS {/TX E D Wf{/fin f D /CW 0 D /LK 0 D /SC 0 D
  1092.  /RT TX D {RT ( ) search{/NW E D pop /RT E D /WH NW SW pop D CW WH add LL gt
  1093.  {TX SC LK SC sub 1 sub NN GI GL{SH cF cS OC
  1094.  2 copy cS ne E cF ne or{NF}{pop pop}ie}{PC /CW WH BW add D}ie
  1095.  /SC LK D}
  1096.  {GL{JC}if
  1097.  /CW CW WH add BW add D /HM t D}ie /GL f D /Ph f D
  1098.  /LK LK NW length 1 add add D}{pop exit}ie}loop
  1099.  /fin t D TX SC LK SC sub GI SH RT () ne{GL not{CC}if}if
  1100.  /LC TX length D /WH RT SW pop D CW WH add Hy{HC SW pop add}if LL gt
  1101.  {RT GL{SH cF cS OC 2 copy cS ne E cF ne or{NF}{pop pop}ie
  1102.  Hy{/Ph t D}if /LL LS D}{NL /LL LS D SH}ie}
  1103.  {RT PC Hy{CC}if /Ph Ph Hy or D}ie RT () ne{/GL t D /HM t D}if}
  1104.  {TX SW pop LL le{TX SH}{/NW () D 0 2 TX length 1 sub
  1105.  {/CW E D TX 0 CW GI dup SW pop LL gt{pop NW SH /HM t D NL/LL W XO sub MR sub D
  1106.  /CW CW 2 sub NN D /TX TX CW TX length CW sub GI D TX BS exit}
  1107.  {/NW E D}ie}for}ie}ie /HM t D}D
  1108. /CC {C0 length 0 gt{JC}if /C0 [C1 L1 YA YB Mf NS NB TB AF Bw] D
  1109.  /C1 () D /L0 L1 D /YA 0 D /YB 0 D /Mf 0 D /NS 0 D /NB 0 D}D
  1110. /JC {C0 aload length 0 gt{pop pop pop NB add /NB E D NS add /NS E D
  1111.  dup Mf gt{/Mf E D}{pop}ie dup YB gt{/YB E D}{pop}ie
  1112.  dup YA gt{/YA E D}{pop}ie pop C1 join /C1 E D /C0 [] D}if}D
  1113. /OC {C0 length 0 gt{C1 L1 L0 sub YA YB Mf NS NB TB AF Bw GL C0 aload pop
  1114.  /Bw E D /AF E D /TB E D /NB E D /NS E D /Mf E D /YB E D /YA E D /C0 [] D
  1115.  /L1 E D /C1 E D Ph{HC SH}if NL /GL E D /Bw E D /AF E D /TB E D /NB E D /NS E D
  1116.  /Mf E D /YB E D /YA E D /L1 E D /LL W L1 sub XO sub MR sub WH sub D /CW 0 D
  1117.  C1 E join /C1 E D}if}D
  1118. /BT {/LB t D dup length string copy RS dup dup () ne E ( ) ne and
  1119.  {/CI 0 D /LS LL D /LL W L1 sub XO sub MR sub D BS}
  1120.  {dup ( ) eq{/GL f D}if dup () eq L1 0 eq or{pop}{SH /BP f D /Ph f D}ie}ie
  1121.  /LB f D} D
  1122. /BL {CP E pop XO E M} D
  1123. /NL {JC /GL f D /SK W XO sub MR sub L1 sub TB{Bw add}if D
  1124.  /YA LF{Mf HM Fl not and PF or{LH mul}if}{0 /LF t D}ie YA 2 copy lt{E}if pop D
  1125.  C1 () ne{/FB YB Mf SA{Sf mul}if 4 div 2 copy lt{E}if pop D}if Fl{/Ya YA D}if
  1126.  CP E pop YA sub YB sub LE neg lt Fl not and PB not and{NP}if NT TL BL
  1127.  OU PF not and PB or{/RE L1 TB{Bw sub}if
  1128.  W XO sub MR sub div YA YB add LE BO add div 2 copy lt{E}if pop D
  1129.  RE 1 gt{BL 1 RE div dup scale}if}if
  1130.  AT 2 le{SK AT mul 2 div YA neg R}if
  1131.  AT 3 eq{0 YA neg R TB{/NB NB 1 sub D /NS NS 1 sub D}if /NB NB 1 sub NN D
  1132.  /A3 NS 6 mul NB add D NS NB add 0 eq
  1133.   {/A1 0 D /A2 0 D}
  1134.   {NS 0 eq{/A1 SK NB div dup J gt{pop 0}if D /A2 0 D}{J A3 mul SK lt
  1135.    {/A1 J D /A2 SK J NB mul sub NS div dup Ab gt{/A1 0 D pop 0}if D}
  1136.    {/A1 SK A3 div D /A2 A1 6 mul D}ie}ie}ie /A1 A1 NN D /A2 A2 NN D}if
  1137.  AT 4 eq{0 YA neg R PH 2 le{PD 0 lt{/PD L1 D}if PD M1 gt{/M1 PD D}if
  1138.  L1 PD sub M2 gt{/M2 L1 PD sub D}if}{DV ID 1 sub get 0 ge{Lo 0 R}if}ie}if
  1139.  F0 cF ne Cs cS ne or{F0 Cs NF}if
  1140.  /ms Ms D /Ms f D CP FB sub
  1141.  C1 cvx exec XO EO sub L1 add TB{BW sub}if dup LM gt{/LM E D}{pop}ie
  1142.  PH 0 eq PH 4 eq or Ms and{HF not{/PO t D /AH t D}if
  1143.  BB CP YA add E AT 3 eq LB and{A1 sub}if TB{BW sub}if E BB}
  1144.  {pop pop}ie Ms HM PH 3 eq and or{/BP f D /Fl f D}if
  1145.  /Lo 0 D /L1 0 D /F0 cF D /Cs cS D BP not{0 YB NN neg R}if
  1146.  OU f1 and mF not and{k2 /f1 f D}if
  1147.  OU PF not and PB or{RE 1 gt{RE dup scale}if}if /Ms ms Ms or D
  1148.  /C1 AF{(Cp )}{()}ie D /YA 0 D /YB 0 D BL
  1149.  AT 4 eq LB not and PH 3 ge and
  1150.  {ID DV length lt{DV ID get dup 0 ge{DO E sub /Lo E D /L1 Lo D}{pop}ie
  1151.  /ID ID 1 add D}if}if /T t D CD{/LN LN 1 add D PD}if
  1152.  /PD -1 D /NS 0 D /NB 0 D /TB f D /Ph f D /Mf 0 D /HM f D} D
  1153. /RS {/TM E D /CN 0 D TM{10 eq{TM CN ( ) PI}if /CN CN 1 add D}forall
  1154.  /CN 0 D /BK HM EN and{0}{1}ie D TM
  1155.  {dup 32 ne{TM CN 3 2 roll put /CN CN 1 add D /BK 0 D}
  1156.  {pop BK 0 eq{TM CN 32 put /CN CN 1 add D}if /BK 1 D}ie}forall
  1157.  TM 0 CN GI dup dup () ne E ( ) ne and
  1158.  {dup CN 1 sub get 32 eq{/EN f D}{/EN t D}ie}if} D
  1159. /join {2 copy length E length add string dup 4 2 roll 2 index 0 3 index
  1160.  PI E length E PI}d
  1161. /WR {(\\n) search{dup () ne BP not or
  1162.  {Li 4 le CP E pop YI Li mul add LE add 0 lt and PL 0 eq and{NP}if
  1163.  SH NL pop /Li Li 1 sub D WR}{pop pop WR}ie}{SH}ie /CI 0 D /BP f D} D
  1164. /SH {dup dup () ne E ( ) ne and PF or CS Mf gt and{/Mf CS D}if
  1165.  T not Wf and{( ) E join /T t D}if dup BP{/MF CS D}if
  1166.  AT 3 eq{2 copy length dup 0 gt{/NB E NB add D
  1167.  {( ) search{/NS NS 1 add D pop pop}{pop exit}ie}loop}{pop pop}ie}if
  1168.  CD PD 0 lt and{dup DC search{SW pop /PD E L1 add D pop pop}{pop}ie}if
  1169.  0 Np dup SW pop L1 add /L1 E D dup () ne
  1170.  {C1 (\\() join E join (\\)) join AU AF and UF or Wf and{( U ) join}if
  1171.  sF{( s ) join}if ( S ) join
  1172.  /C1 E D dup length 1 sub get 32 eq /TB E D /Bw BW D}{pop pop}ie} D
  1173. /BG {AI LG BC add add 0 eq} D
  1174. /ON {OU{Ty AR AI NN get dup 1 add Ln Ns Ty 2 mod 0 eq{(.  )}{(\\)  )}ie join
  1175.  dup SW pop neg 0 R CP E 0 lt{0 E M}{pop}ie CP BB show /Ms t D}if} D
  1176. /Ln {AR AI 3 -1 roll put}D
  1177. /SP {dup CI lt BP not and{dup CI sub 0 E R /CI E D}{pop}ie} D
  1178. /BN {PF{WR /HM f D}{BT NL}ie} D
  1179. /NN {dup 0 lt{pop 0}if} D
  1180. /h {HI 0 gt{(h) HI ST cvs join cvx exec dup 1 get E
  1181.  Nf{0 get E join}{pop}ie}{()}ie} D
  1182. /H {/fn FN D /Hi E 1 add D 1 sub /HL E D /H2 HL 2 add D /GS EZ H2 get D
  1183.  E Tm H2 get GS mul BE dup 0 gt{1 sub}{pop EG H2 get dup 0 lt{pop AT}if}ie NA
  1184.  WW Np /SL SL 1 add D /FN EF H2 get D GS Ey H2 get FS
  1185.  EU H2 get Sc Hs not HL Hl lt and Hs HL hl lt and or Hi 0 eq or
  1186.  {/HI Hi D /Hs t D /hl HL D /hL HL D}if HL Hl lt{/hi Hi D}if
  1187.  Nf HI 0 gt and{(h) Hi ST cvs join cvx exec 0 get WB}if
  1188.  /HF t D /AH f D /PO f D} D
  1189. /EH {Bm H2 get GS mul BE OA /SL SL 1 sub NN D /CF 0 D /FN fn D
  1190.  SZ SL get FR SL get FS /HF f D /GS Ts D ()Ec} D
  1191. /P {E PF{WR}{PO{EP}{BN}ie Ts 4 mul Np AE not{Tm 0 get Ts mul neg SP}if
  1192.  dup 0 ge AH and{Pi Pd}if}ie 1 sub dup 0 lt{pop AV AL get}if /AT E D /PO t D} D
  1193. /EP {PF{WR}{BN Ts 4 mul Np}ie AE not{Bm 0 get Ts mul neg SP}if
  1194.  /AT AV AL get D /PO f D} D
  1195. /BE {E PO{EP}{BN}ie Ts 4 mul Np neg SP} D
  1196. /HR {/Aw W EO sub D /RW E dup 0 gt{Aw mul}{neg}ie dup Aw gt{pop Aw}if D /RZ E D
  1197.  E BN Ts neg SP 1 sub 2 div Aw RW sub mul EO add CP E pop M PF{0 Ps neg R}if
  1198.  0 Np OU{gsave RZ LW Cf{Hc VC}{0 Sg}ie CP BB RW 0 RL CP BB stroke grestore}if
  1199.  /CI 0 D /BP f D PF not{Ts neg SP}if /Ms t D} D
  1200. /AD {I NL EG 14 get dup 0 lt{pop AT}if NA /AE t D Tm 14 get Ts mul neg SP
  1201.  Cf{EU 14 get dup -1 eq{pop CA CL get}if Sc}if} D
  1202. /DA {BN ()ES OA /AE f D ()Ec Bm 14 get Ts mul neg SP} D
  1203. /PR {/MW E D /Li E D Tm 1 get Ps mul BE 0 NA /FN Fp D /PF t D SI /SL SL 1 add D
  1204.  /CF 0 D Ps CS mul Ts div MW WC mul CS mul Ts div dup LL gt PL 0 eq and
  1205.  {LL div div}{pop}ie Ey 1 get FS CP E pop LE add YI neg div cvi dup Li lt
  1206.  AH and{4 lt YI Li mul 5 mul LE add 0 gt or PL 0 eq and{NP}if}{pop}ie
  1207.  EU 1 get Sc /GS Ps D}D
  1208. /RP {WR NL () /PF f D SI /FN 0 D ES Bm 1 get Ps mul neg SP OA /GS Ts D} D
  1209. /SI {/XO Lm 15 get BC NN mul Lm 16 get AI UI sub NN mul add
  1210.  Lm 17 get UI NN mul add Lm 20 get LG NN mul add Ts mul
  1211.  PF{Lm 1 get Ps mul add}if EO add D
  1212.  /MR Rm 15 get BC NN mul Rm 16 get AI UI sub NN mul add
  1213.  Rm 17 get UI NN mul add Rm 20 get LG NN mul add Ts mul
  1214.  PF{Rm 1 get Ps mul add}if D /LL W XO sub MR sub D} D
  1215. /DT {BN /LG LG 1 sub D SI /LG LG 1 add D WW 2 div Np BL} D
  1216. /DD {WB Cc 0 eq L1 0 eq or Lm 20 get Ts mul L1 sub TB{BW add}if Ts 2 div lt or
  1217.  NL /LF E D SI BL} D
  1218. /DL {Dc LG Cc put /Cc E D BG{Tm 18 get Ts mul BE}{BN}ie /LG LG 1 add D BL} D
  1219. /LD {BN LG 0 gt{/LG LG 1 sub D}if /Cc Dc LG get D SI
  1220.  BG{()Bm 18 get Ts mul BE}if BL} D
  1221. /UL {BG{Tm 17 get Ts mul BE}{BN}ie NR AI NN 0 put /UI UI 1 add D
  1222.  /AI AI 1 add D SI BL} D
  1223. /LU {BN /UI UI 1 sub D /AI AI 1 sub D SI BG{()Bm 17 get Ts mul BE}if BL} D
  1224. /OL {E BG{Tm 16 get Ts mul BE}{BN}ie TR AI NN Ty put /Ty E D NR AI NN 1 put
  1225.  /AI AI 1 add D SI BL 1 Ln} D
  1226. /LO {BN /AI AI 1 sub D /Ty TR AI get D SI BG{()Bm 16 get Ts mul BE}if BL} D
  1227. /LI {E BN -1 SP /BP f D /CI 0 D 0 Np NR AI 1 sub NN get 1 eq
  1228.  {dup dup 0 gt E 4 le and{/Ty E D}{pop}ie
  1229.  /L1 L1 Ty AR AI NN get Ns SW pop XO sub dup 0 lt{pop 0}if add D ( ON )}
  1230.  {pop ( B )}ie C1 E join /C1 E D CS Mf gt{/Mf CS D}if BL} D
  1231. /BQ {Tm 15 get Ts mul BE /BC BC 1 add D SI BL} D
  1232. /QB {Bm 15 get Ts mul BE /BC BC 1 sub D SI BL} D
  1233. /Al {E EP 1 sub dup 0 lt{pop AV AL get}if NA} D
  1234. /Ea {EP OA} D
  1235. /WB {PF{WR}{BT}ie} D
  1236. /F1 {WB /FN 0 D CS 0 FS} D
  1237. /F2 {WB /FN WI D CS 0 FS} D
  1238. /HY {/Hy t D WB /Hy f D} D
  1239. /YH {WB} D
  1240. /A {/LT E D LT 1 eq{/RN E D}if /Lh E D WB /AF t D /C1 C1 ( Cp ) join D
  1241.  Lc{Cl Sc}if} D
  1242. /EA {Lc AF and{Ec}{WB}ie TL Pa AF and Lh 0 ne and
  1243.  {( \\() Lh join (\\)) join /AF f D WB}if /AF f D} D
  1244. /TL {C1 ( Tl ) apa /C1 E D} d
  1245. /apa {AF OU and Lh 0 ne LT 1 eq or and{LT 1 eq{RN ( /) E ST cvs join}
  1246.  {(\\() Lh join (\\)) join}ie E join join}{pop}ie} d
  1247. /Cp {/Xc CP /Yc E D D} D
  1248. /SS {Cf{dup 0 ge{EU E get dup -1 eq{pop CA CL get}if}{pop CA CL get}ie Sc}
  1249.  {pop}ie SZ SL get /SL SL 1 add D} D
  1250. /I {WB 8 SS 1 FS} D
  1251. /EM {WB 8 SS /CF CF 1 xor D 0 FS} D
  1252. /BD {WB 9 SS 2 FS} D
  1253. /TT {WB 10 SS /FN Fp D 0 FS} D
  1254. /KB {WB 11 SS /FN Fp D 2 FS} D
  1255. /CT {WB 12 SS 1 FS} D
  1256. /SM {WB 13 SS /FN Fp D 0 FS} D
  1257. /Q {/QL QL 1 add D QO QL 2 mod get La get join WB} D
  1258. /EQ {QC QL 2 mod get La get join WB /QL QL 1 sub D} D
  1259. /RO {WB -1 SS /CF 0 D 0 FS} D
  1260. /SY {WB -1 SS -1 FS} D
  1261. /ES {WB /SL SL 1 sub NN D /CF 0 D /FN FO SL get D SZ SL get FR SL get FS ()Ec}D
  1262. /FZ {3 sub 1.2 E exp GS mul E WB TL /C1 C1 ( Cp ) join D /SL SL 1 add D 0 FS} D
  1263. /Ef {WB TL ()ES /C1 C1 ( Cp ) join D} D
  1264. /BZ {dup /Bf E D FZ}D
  1265. /Sc {dup -1 ne Cf and{/CL CL 1 add D dup 0 eq{pop [0 0 0]}if
  1266.  dup CA E CL E put VS ( VC ) join C1 E join /C1 E D}{pop}ie} D
  1267. /Ec {WB Cf{/CL CL 1 sub NN D CA CL get VS ( VC ) join C1 E join /C1 E D}if} D
  1268. /VS {dup type /arraytype eq{([) E {ST cvs join ( ) join}forall (]) join}if} D
  1269. /VC {{255 div}forall setrgbcolor} D
  1270. /Sl {dup type /integertype ne{Ds}if /La E D WB}d
  1271. /UN {WB /UF t D} D
  1272. /NU {WB /UF f D} D
  1273. /SE {WB /sF t D} D
  1274. /XE {WB /sF f D} D
  1275. /sM {/C1 C1 ( k1 ) join D}d
  1276. /eM {/C1 C1 ( k2 ) join D}d
  1277. /k1 {/YC CP E pop Ts add D /mF t D /f1 t D}d
  1278. /k2 {gsave 3 LW -9 CP E pop Ts 0.2 mul sub M -9 YC L stroke grestore /mF f D}d
  1279. /Ac {/AC E D WB}d
  1280. /Ca {eA{( \\()join AC join(\\) )join}if WB}d
  1281. /s {OU{gsave 0 CS .25 mul R dup SW pop CJ 0 RL stroke grestore}if}D
  1282. /CJ {AT 3 eq LB and{E dup dup length 1 sub A1 mul E
  1283.  {( ) search{pop pop E A2 add E}{pop exit}ie}loop 3 -1 roll add
  1284.  W CP pop sub 2 copy gt{E}if pop}if}D
  1285. /So {/Co E D} D
  1286. /SO {C1 Yo ST cvs join ( So ) join /C1 E D (j) SW pop 2 div Pd} D
  1287. /Se {E WB CS E div Pd}D
  1288. /Pd {dup type /stringtype eq{SW pop}if dup /L1 E L1 add D
  1289.  ST cvs ( 0 R ) join C1 E join /C1 E D} D
  1290. /Sp {0.35 CO} D
  1291. /Sb {-0.2 CO} D
  1292. /CO {OV Io Yo put /Yo E CS mul Yo add D /Io Io 1 add D -1.5 Io mul 3 add FZ SO
  1293.  CS Yo add dup YA gt{/YA E D}{pop}ie
  1294.  Yo neg dup YB gt{/YB E D}{pop}ie} D
  1295. /Es {ES /Io Io 1 sub NN D /Yo OV Io get D SO} D
  1296. /SB {/N2 0 D 0 1 NI{/N E D{IX N2 get 0 lt{/N2 N2 1 add D}{exit}ie}loop
  1297.  /K WS N get FC N get mul D /NY AY N2 get D /BV NY array D
  1298.  0 1 NY 1 sub{/TM K string D currentfile TM readhexstring pop pop BV E TM put}
  1299.  for BM N BV put /N2 N2 1 add D}for} D
  1300. /IC [{/MA E D /MB 0 D}{2 div /MA E D /MB MA D}{/MB E CS sub D /MA CS D}
  1301.  {pop /MA YS AB mul D /MB 1 AB sub YS mul D}{pop /MA 0 D /MB 0 D}] D
  1302. /IP {BV N get /N N 1 add D} D
  1303. /II {/K E D IX K get 0 lt{/EC E D}if /TY E D
  1304.  TY 4 eq{/Y E D /X E D}if TY 3 eq{/AB E D}if
  1305.  /XW AX K get D /YW AY K get D /IS SG IT K get get D /XS XW IS mul D
  1306.  /YS YW IS mul D YS IC TY get exec /MA MA Fl not{3 add}if D} D
  1307. /IM {II /ty TY D /xs XS D /ys YS D /ya YA D /yb YB D /ma MA D /mb MB D /k K D
  1308.  /ec EC D /BP f D /CI 0 D WB TL L1 xs add dup XO add MR add W gt
  1309.  {pop /ma ma Fl{3 add}if D NL /YA ma D /YB mb D /YS ys D /L1 xs D}
  1310.  {/L1 E D ma YA gt{/YA ma D}if mb YB gt{/YB mb D}if}ie /TB f D
  1311.  OU{CP E pop YS sub LE neg lt Fl not and PB not and{NP /YA ma D /YB mb D}if
  1312.  /BP f D ty ST cvs ( ) join IX k get 0 lt{(\\() join ec join (\\) ) join}if
  1313.  k ST cvs join ty 3 eq{AB ST cvs ( ) join E join}if
  1314.  ty 4 eq{X ST cvs ( ) join Y ST cvs join ( ) join E join}if C1 E join
  1315.  ( DI ) join FP 2 eq FP 1 eq AF and or{( FM ) join}if
  1316.  ( Il Cp ) apa /C1 E D /EN f D}if /HM t D /T f D} D
  1317. /DI {II /Xc CP /Yc E D D /YN YW neg D /HM t D /CI 0 D /K2 IX K get D gsave
  1318.  TY 4 eq{OX X IS mul add OY FY add YS sub Y IS mul sub}
  1319.  {/FY YS D CP MB sub 2 copy /OY E D /OX E D}ie
  1320.  translate K2 0 ge{/DP AZ K2 get D /BV BM K2 get D XS YS scale /N 0 D XW YW DP
  1321.  [XW 0 0 YN 0 YW] {IP} FC K2 get 1 eq{image}{f 3 colorimage}ie}
  1322.  {EX}ie grestore XS 0 R /Ms t D} D
  1323. /FM {gsave 0 Sg CP MB sub translate XS neg 0 M 0 YS RL XS 0 RL 0 YS neg RL
  1324.  XS neg 0 RL stroke grestore} D
  1325. /NA {/AT E D /AL AL 1 add D AV AL AT put} D
  1326. /OA {AL 0 gt{/AL AL 1 sub D /AT AV AL get D}if} D
  1327. /D1 {/BR {CP E pop E BN Mb{CP E pop eq{0 YI R}if}{pop}ie} D
  1328.  /Sn {OU{C1 E ST cvs join ( Ld ) join /C1 E D}{pop}ie} D} D
  1329. /D1 {/BR {BN} D /Sn {OU {C1 E ST cvs join ( Ld ) join /C1 E D} {pop} ie} D} D
  1330. /TC {/TF t D /ML 0 D HN{SW pop dup ML gt{/ML E D}{pop}ie}forall NP /RM RM not D
  1331.  RC /OU Tc D Ep /PN 0 D Ms not TP and{Ip}if /W IW ML sub Ts sub D
  1332.  /A0 0 D TH{/BR {( ) join BT} D /Sn {pop} D /Ti () D /Au () D}if} D
  1333. /TN {0 eq{E EA PF HF or not XR and{HN E get Xr}{pop}ie}
  1334.  {OU{Tn 0 ge{() BN}if /Tn E D}{pop}ie WB}ie} D
  1335. /NT {OU LB not and Tn 0 ge and{PL 0 eq{Ms not{CS CF FS}if CP dup
  1336.  /y E YA sub D W 9 sub CS -1.8 mul XO L1 add 2 add{y M (.) show}for
  1337.  HN Tn get dup SW pop IW E sub y M show CP BB M}if /Tn -1 D}if} D
  1338. /Ld {/DN E D HN DN Pn put [/View [/XYZ -4 Fl{PS}{CP YA add US E pop}ie null]
  1339.  /Dest DN ST cvs cvn /DEST pdfmark} D
  1340. /C {ND 1 eq{1 sub}if TI mul /XO E D NL Nf not{pop()}if 0 3 -1 roll 1 A} D
  1341. /OP {BP not{NP}if PN 2 mod 0 eq{NP}if}D
  1342. /Ep {Xp PN 2 mod 0 eq and{/Pn (-) D showpage /PM 1 D LA}if}D
  1343. /Dg [73 86 88 76 67 68 77] D
  1344. /Rd [0 [1 1 0][2 1 0][3 1 0][2 1 1][1 1 1][2 2 1][3 3 1][4 4 1][2 1 2]] D
  1345. /Ns {/m E D /c E 32 mul D /j m 1000 idiv D /p j 12 add string D
  1346.  c 96 le m 0 gt and{c 32 le {/i 0 D /d 77 D /l 100 D /m m j 1000 mul sub D
  1347.   j -1 1 {pop p i d c add put /i i 1 add D}for
  1348.   4 -2 0 {/j E D /n m l idiv D /m m n l mul sub D /d Dg j get D
  1349.    n 0 gt {/x Rd n get D x 0 get -1 1 {pop p i d c add put /i i 1 add D}for
  1350.    p i x 1 get sub Dg x 2 get j add get c add put}if /l l 10 idiv D
  1351.   }for p 0 i GI}
  1352.   {/i ST length 1 sub D m {1 sub dup 0 ge{dup 26 mod c add 1 add
  1353.    ST i 3 -1 roll put 26 idiv dup 0 eq{pop exit}if}if /i i 1 sub D}loop
  1354.    ST i ST length i sub GI}ie}
  1355.  {m p cvs}ie} D
  1356. /US {matrix currentmatrix matrix defaultmatrix matrix invertmatrix
  1357.  matrix concatmatrix transform} D
  1358. /GB {Gb{US}if}D
  1359. /Tl {/Rn E D Xc CP pop ne{
  1360.  [/Rect [Xc 1 sub Yc cS 0.25 mul sub GB CP E 1 add E cS 0.85 mul add GB]
  1361.   /Subtype /Link /Border [0 0 Cf Lc and LX and AU or{0}{1}ie] Rn type
  1362.   /nametype eq {/Dest Rn}{/Action [/Subtype /URI /URI Rn] Cd}ie
  1363.   /ANN pdfmark}if} D
  1364. /Il {/Rn E D [/Rect [Xc Yc GB Xc XS add Yc YS add GB] /Subtype /Link
  1365.  /Border [0 0 0] Rn type /nametype eq{/Dest Rn}
  1366.  {/Action [/Subtype /URI /URI Rn] Cd}ie /ANN pdfmark} D
  1367. /XP {[{/Z Bz 2 div D Z 0 R Z Z RL Z neg Z RL Z neg Z neg RL Z Z neg RL}
  1368.  {Bz 0 RL 0 Bz RL Bz neg 0 RL 0 Bz neg RL}
  1369.  {0 -5 R Bz 0 RL 0 21 RL Bz neg 0 RL 0 -21 RL}]} D
  1370. /MS {/Sm E D WB}D
  1371. /O {BN()Sm BX} D
  1372. /BX {/Bt E D Bt 2 lt{CS 0.8 mul}{11 mul}ie W XO sub MR sub 2 copy gt{E}if pop
  1373.  /HZ E D WB Bt 2 eq{HZ ST cvs ( ) join}{()}ie
  1374.  Bt ST cvs join ( Bx ) join HM{( ) Pd}if
  1375.  L1 HZ add XO add MR add W gt{NL}if C1 E join /C1 E D /L1 L1 HZ add D /T f D
  1376.  ( ) WB Bt 2 lt{YA CS .8 mul lt{/YA CS .8 mul D}if}
  1377.  {YB 5 lt{/YB 5 D}if YA 21 lt{/YA 21 D}if}ie /CI 0 D} D
  1378. /Bx {dup 2 eq{E /Bz E D}{/Bz CS .8 mul D}ie
  1379.  OU {gsave 0 Sg XP E get exec stroke grestore}{pop}ie Bz 0 R /Ms t D} D
  1380. /SD {FD 4 mul Dy add DZ NF newpath 0 0 M DX t charpath pathbbox
  1381.  3 -1 roll sub /DY E D E dup /X1 E D sub WM mul WX DY mul add WM DG mul E div
  1382.  /DF E D /DR WX DF mul DY mul WM div 2 div D} d
  1383. /Sd {gsave 0 IL Di mul neg translate IL IW atan Di 0 eq{neg}if rotate
  1384.  FD 4 mul Dy add DZ NF DR X1 sub DY 2 div neg M cD VC DX show grestore} d
  1385. /RC {/AI 0 D /LG 0 D /BC 0 D /UI 0 D /PF f D /Cc 0 D /Dc 10 array D
  1386.  /NR [0 1 9{pop 0}for] D /La Ds D /AR 10 array D /TR 10 array D /AV 30 array D
  1387.  SI /AL -1 D /AT A0 D AT NA /OV 9 array D /Yo 0 D /Co 0 D /Io 0 D /Hy f D
  1388.  /Ph f D /CL -1 D Ct Sc}D
  1389. /ZF {/FR [0 1 30{pop 0}for] D /SZ [0 1 30{pop 0}for] D /FO [0 1 30{pop 0}for] D
  1390.  /SL 0 D /CF 0 D /FN 0 D 0 Ts SF}D
  1391. /QO [[($qo)][($qo2)]] D
  1392. /QC [[($qc)][($qc2)]] D
  1393. /Hf EF length 2 sub D
  1394. /Hz EZ Hf get D
  1395. /HS Ey Hf get D
  1396. /Fz EZ Hf 1 add get D
  1397. /Fs Ey Hf 1 add get D
  1398. /LE IL D
  1399. /Ps EZ 1 get D
  1400. /Fp EF 1 get D
  1401. /XO 0 D
  1402. /YI 0 D
  1403. /CI 0 D
  1404. /FP 0 D
  1405. /WW Ts 7 mul D
  1406. /Mf 0 D
  1407. /YA 0 D
  1408. /YB 0 D
  1409. /Cs Ts D
  1410. /GS Ts D
  1411. /F0 0 D
  1412. /NS 0 D
  1413. /NB 0 D
  1414. /N 0 D
  1415. /C0 [] D
  1416. /C1 () D
  1417. /Lo 0 D
  1418. /L1 0 D
  1419. /LM 0 D
  1420. /PH 0 D
  1421. /EC 0 D
  1422. /Lh 0 D
  1423. /LT 0 D
  1424. /CH 1 string D
  1425. /ST 16 string D
  1426. /CA 9 array D
  1427. /HC (\\255) D
  1428. /HM f D
  1429. /PF f D
  1430. /EN f D
  1431. /TB f D
  1432. /UF f D
  1433. /sF f D
  1434. /AE f D
  1435. /AF f D
  1436. /BP t D
  1437. /CD f D
  1438. /PA t D
  1439. /GL f D
  1440. /T t D
  1441. /HF f D
  1442. /AH f D
  1443. /SA f D
  1444. /PB f D
  1445. /f1 f D
  1446. /mF f D
  1447. /OX 0 D
  1448. /OY 0 D
  1449. /FY 0 D
  1450. /EO 0 D
  1451. /FB 0 D
  1452. /PL 0 D
  1453. /Bw 0 D
  1454. /PD -1 D
  1455. /TP f D
  1456. /TH $th D
  1457. /Ty 4 D
  1458. /Tn -1 D
  1459. /Fl t D
  1460. /LB t D
  1461. /PM 1 D
  1462. /Ms f D
  1463. /Ba f D
  1464. /Bb f D
  1465. /Hl 3 D
  1466. /hl 6 D
  1467. /hL 6 D
  1468. /Hs f D
  1469. /HI 0 D
  1470. /hi 0 D
  1471. /PO t D
  1472. /TE f D
  1473. /LF t D
  1474. /BO 0 D
  1475. /Sm 1 D
  1476. /Bf 3 D
  1477. /A1 0 D
  1478. /A2 0 D
  1479. /Ds $lid{'en'} D
  1480. /QL -1 D
  1481. /Cb Db D
  1482. /Ct Dt D
  1483. /Cl Dl D
  1484. $tbl=<<EOT;
  1485. /TS {
  1486.  tables E get /table E D
  1487.  table aload pop /rdesc E D /cdesc E D /tdesc E D
  1488.  tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D
  1489.   /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D
  1490.   /flow E D /clear E D /tclass E D pop pop
  1491.  /w W D /eps 0.1 D /OU f D /PL 1 D
  1492.  /FN EF 21 get D EZ 21 get Ey 21 get FS
  1493.  0 1 1{
  1494.   /pass E D
  1495.   0 1 nrow{
  1496.    /irow E D
  1497.    /cells rdesc irow get 6 get D
  1498.    0 1 ncol{
  1499.     /icol E D
  1500.     /cell cells icol get D
  1501.     cell 0 ne{
  1502.      cell aload pop /CB E D pop pop pop
  1503.      /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D
  1504.      /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D
  1505.      /cmin E D /proc E D
  1506.      rspan 0 eq{/rspan nrow irow sub 1 add D}if
  1507.      cspan 0 eq{/cspan ncol icol sub 1 add D}if
  1508.      pass 0 eq cspan 1 eq and pass 1 eq cspan 1 gt and or{
  1509.       /W 1e5 D /LL W D /PH 1 D
  1510.       ctype 1 eq{() BD}if
  1511.       RC align NA
  1512.       AT 4 eq{/CD t D /DC dp D /LN 0 D /M1 0 D /M2 0 D}{/CD f D}ie
  1513.       0 0 M /LM 0 D proc exec BN
  1514.       AT 4 eq{
  1515.        LN array astore cell 15 3 -1 roll put
  1516.        cdesc icol get dup dup 5 get M1 lt{5 M1 put}{5 get /M1 E D}ie
  1517.        dup 6 get M2 lt{6 M2 put}{6 get /M2 E D}ie
  1518.        /LM M1 M2 add D
  1519.       }if
  1520.       /CD f D
  1521.       /thiswid LM left add right add eps add D
  1522.       /oldmin 0 D /oldmax 0 D
  1523.       0 1 cspan 1 sub{
  1524.        icol add cdesc E get dup 2 get /oldmax E oldmax add D
  1525.        1 get /oldmin E oldmin add D
  1526.       }for
  1527.       thiswid oldmax ge{
  1528.        0 1 cspan 1 sub{
  1529.         icol add cdesc E get dup 2 E 2 get oldmax 0 eq
  1530.          {pop thiswid cspan div}{thiswid mul oldmax div}ie
  1531.         put
  1532.        }for
  1533.       }if
  1534.       nowrap 1 eq{
  1535.        thiswid oldmin ge{
  1536.         0 1 cspan 1 sub{
  1537.          icol add cdesc E get dup 1 E 1 get oldmin 0 eq
  1538.           {pop thiswid cspan div}{thiswid mul oldmin div}ie
  1539.          put
  1540.         }for
  1541.        }if
  1542.       }{
  1543.        /W 0 D /LL W D /PH 2 D
  1544.        ctype 1 eq{() ES () BD}if
  1545.        0 0 M /LM 0 D RC proc exec BN
  1546.        /thiswid LM left add right add eps add D
  1547.        thiswid oldmin ge{
  1548.         0 1 cspan 1 sub{
  1549.          icol add cdesc E get dup 1 E 1 get oldmin 0 eq
  1550.           {pop thiswid cspan div}{thiswid mul oldmin div}ie
  1551.          put
  1552.         }for
  1553.        }if
  1554.       }ie
  1555.       ctype 1 eq{() ES}if
  1556.      }if
  1557.     }if
  1558.    }for
  1559.   }for
  1560.  }for
  1561.  /tmin 0 D /tmax 0 D
  1562.  0 1 ncol{
  1563.   cdesc E get dup 1 get E 2 get 2 copy gt{pop dup}if
  1564.   tmax add /tmax E D tmin add /tmin E D
  1565.  }for
  1566.  twid 0 lt{twid neg IW gt{IW neg}{twid}ie /twid E D}if
  1567.  tdesc 0 twid neg tmin 2 copy lt{E}if pop put
  1568.  tdesc 1 twid neg tmax 2 copy lt{E}if pop put
  1569.  /W w D /LL W D /OU t D /PH 0 D /PL 0 D
  1570. /PT {
  1571.  /PL PL 1 add D
  1572.  tables E get /table E D Tm 21 get Ts mul BE
  1573.  PL 2 ge{save}if
  1574.  /SL SL 1 add D /FN EF 21 get D EZ 21 get Ey 21 get FS
  1575.  table aload pop /rdesc E D /cdesc E D /tdesc E D
  1576.  tdesc aload pop /capalg E D /caption E D /rules E D /frame E D /nfoot E D
  1577.   /nhead E D /ncol E D /nrow E D /border E D /twid E D /units E D /talign E D
  1578.   /flow E D /clear E D /tclass E D /tmax E D /tmin E D
  1579.  /w W D /xo XO D /mr MR D /ll LL D /lg LG D /ai AI D /bc BC D /nr NR D /ar AR D
  1580.  /tr TR D /ui UI D /ph PH D /a0 A0 D /pf PF D /at AT D /av AV D /al AL D
  1581.  /Le LE D /la La D
  1582.  talign 0 lt{/talign AL 0 gt{AV AL get}{A0 2 le{A0}{0}ie}ie D}if
  1583.  ph 1 eq ph 2 eq or{
  1584.   NL ph 1 eq{tmax}{tmin}ie dup XO add LM gt{/LM E XO add D}{pop}ie LM E
  1585.   /PH 3 D /LE 1e5 D RC %ZF
  1586.   border 0 gt{/border 1 D}if
  1587.   /twidth 0 D /avail W xo sub D
  1588.   twid 0 eq{0 1 ncol{cdesc E get dup 2 get E 3 get dup 0 gt{div neg dup twid lt
  1589.    {/twid E D}{pop}ie}{pop pop}ie}for}if
  1590.   /twid twid dup 0 lt{neg avail 2 copy gt{E}if pop}{avail mul}ie D
  1591.   /OK t D 0 1 ncol{cdesc E get dup 1 get E 3 get twid mul gt{/OK f D}if}for
  1592.   0 1 ncol{
  1593.    cdesc E get dup 1 get /colmin E D dup 3 get /cwid E twid mul D dup
  1594.    tmax avail le{2 get}if
  1595.    tmin avail le tmax avail gt and{
  1596.     dup 2 get E 1 get dup 3 1 roll sub avail tmin sub mul tmax tmin sub div add
  1597.    }if
  1598.    tmin avail gt{1 get}if
  1599.    0 E colmin cwid lt OK and{pop cwid}if dup /twidth E twidth add D put
  1600.   }for
  1601.   /OU f D CP
  1602.   tmin twid le{
  1603.    0 1 ncol{cdesc E get dup 0 get twidth div twid mul 0 E put}for
  1604.    /twidth twid D
  1605.   }if
  1606.   CP printcap CP E pop sub /caphig E D pop
  1607.   0 1 1{
  1608.    /pass E D
  1609.    0 1 nrow{
  1610.     /irow E D
  1611.     /cells rdesc irow get 6 get D
  1612.     0 1 ncol{
  1613.      /icol E D
  1614.      /cell cells icol get D
  1615.      cell 0 ne{
  1616.       cell aload pop /CB E D pop pop pop
  1617.       /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D
  1618.       /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D
  1619.       /cmin E D /proc E D
  1620.       rspan 0 eq{/rspan nrow irow sub 1 add D}if
  1621.       cspan 0 eq{/cspan ncol icol sub 1 add D}if
  1622.       /W 0 D
  1623.       0 1 cspan 1 sub{icol add cdesc E get 0 get /W E W add D}for
  1624.       pass 0 eq rspan 1 eq and pass 1 eq rspan 1 gt and or{
  1625.        ctype 1 eq{() BD}if
  1626.        /W W left sub right sub D /XO 0 D /EO 0 D SI
  1627.        /A0 align D RC align NA
  1628.        AT 4 eq{
  1629.         /DC dp D /DO 0 D /ID 1 D
  1630.         0 1 DV length 1 sub{DV E get dup DO gt{/DO E D}{pop}ie}for
  1631.         /Lo DO DV 0 get sub D /L1 Lo D
  1632.        }if
  1633.        0 0 M /BP t D /Fl t D /MF 0 D /FB 0 D
  1634.        proc exec T not{/CI 0 D}if BN 0 FB neg R MF 0 eq{/MF CS D}if
  1635.        CP /thishig E neg bot add top add CI add D pop
  1636.        cell 16 MF put cell 17 Ya put cell 18 thishig put
  1637.        valign 4 eq{
  1638.         /below thishig Ya sub D
  1639.         rdesc irow get dup dup 4 get Ya lt
  1640.          {4 Ya put}{4 get /Ya E D}ie
  1641.         dup 5 get below lt{5 below put}{5 get /below E D}ie
  1642.         /thishig Ya below add D
  1643.        }if
  1644.        ctype 1 eq{()ES}if
  1645.        /oldhig 0 D
  1646.        0 1 rspan 1 sub{
  1647.         irow add rdesc E get 0 get /oldhig E oldhig add D
  1648.        }for
  1649.        thishig oldhig ge{
  1650.         0 1 rspan 1 sub{
  1651.          irow add rdesc E get dup 0 E 0 get oldhig 0 eq
  1652.           {pop thishig rspan div}{thishig mul oldhig div}ie
  1653.          put
  1654.         }for
  1655.        }if
  1656.       }if
  1657.      }if
  1658.     }for
  1659.    }for
  1660.   }for M RC %ZF
  1661.   /thight 0 D /racc 0 D /maxh 0 D /brk 0 D /rbeg nhead nfoot add D
  1662.   rbeg 1 nrow{
  1663.    rdesc E get dup 0 get dup /thight E thight add D
  1664.    brk 0 eq{/racc E D}{/racc E racc add D}ie
  1665.    racc maxh gt{/maxh racc D}if 2 get /brk E D
  1666.   }for
  1667.   ph 3 ge{thight caphig add E}if
  1668.   ph 0 eq ph 4 eq or{
  1669.    /PH 4 D /LE Le D /OU Ou D /yoff 0 D /headsz 0 D
  1670.    0 1 nhead 1 sub{rdesc E get 0 get headsz add /headsz E D}for
  1671.    /footsz 0 D
  1672.    0 1 nfoot 1 sub{rdesc E nhead add get 0 get footsz add /footsz E D}for
  1673.    /ahig LE BO add MI add D /maxh maxh headsz add footsz add D
  1674.    /thight thight headsz add footsz add D
  1675.    tmin avail gt maxh ahig gt or
  1676.     {/Sf avail tmin div dup ahig maxh div gt{pop ahig maxh div}if D /SA t D}
  1677.     {/Sf 1 D}ie
  1678.    tclass 1 eq thight LE 15 sub gt and
  1679.     {/SA t D LE 15 sub thight div dup Sf lt{/Sf E D}{pop}ie}if
  1680.    SA{Sf Sf scale /ll ll Sf div D /xo xo Sf div D /LE LE Sf div D
  1681.     /mr mr Sf div D /BO BO Sf div D /ahig ahig Sf div D}if
  1682.    nhead nfoot add getwid
  1683.    LE CP E pop add capalg 0 eq{caphig sub}if dup headsz sub footsz sub rwid lt
  1684.    E thight lt thight ahig lt and or{NP}if
  1685.    capalg 0 eq{printcap -8 SP}if
  1686.    CP /ycur E D pop
  1687.    printhead
  1688.    rbeg 1 nrow{/row E D row
  1689.     getwid
  1690.     ycur yoff add rwid sub footsz sub LE add 0 lt
  1691.     {nfoot 0 gt{printfoot}if Tf NP /rbeg irow1 D
  1692.      Ba{MI /MI MI SA{Sf div}if D MI SP /MI E D}if
  1693.      CP /ycur E D pop /yoff 0 D printhead}if
  1694.     irow1 printrow
  1695.    }for
  1696.    printfoot /row row 1 add D Tf
  1697.    0 ycur yoff add M
  1698.    capalg 1 eq{/EO 0 D SI -3 SP printcap}if
  1699.    Sf 1 lt{1 Sf div dup scale /ll ll Sf mul D /xo xo Sf mul D /LE LE Sf mul D
  1700.     /mr mr Sf mul D /BO BO Sf mul D /SA f D}if
  1701.    /EO 0 D
  1702.   }if
  1703.  /W w D /XO xo D /MR mr D /LL ll D /LG lg D /AI ai D /BC bc D /NR nr D /AR ar D
  1704.  /TR tr D /UI ui D /PH ph D /A0 a0 D /PF pf D /AT at D /AV av D /AL al D
  1705.  /La la D
  1706.  /SL SL 1 sub NN D /CF 0 D /FN 0 D SZ SL get FR SL get FS Wf not{()F2}if
  1707.  PL 2 ge{Ms E restore Ms or /Ms E D PH 1 eq PH 2 eq or
  1708.   {/LM E D}if PH 3 ge{/CI 0 D NL 0 E neg R}if
  1709.  /PL PL 1 sub D /CI 0 D /BP f D /PO f D () Bm 21 get Ts mul BE BL %CF CS SF
  1710. /printcap{
  1711.  capalg 0 ge{
  1712.   SA{/W w Sf div D}
  1713.    {talign 1 eq{/XO xo ll twidth sub 2 div add D}if
  1714.     talign 2 eq{/XO xo ll twidth sub add D}if
  1715.     /W XO twidth add D
  1716.    }ie /XO xo D /LL W XO sub MR sub D
  1717.   /PA f D /Fl capalg 0 eq D
  1718.   1 NA BL caption exec BN OA /PA t D
  1719. /getwid{
  1720.  /irow1 E D
  1721.  /irow2 irow1 D
  1722.  /rwid 0 D
  1723.  {rdesc irow2 get dup 0 get rwid add /rwid E D 2 get 0 eq
  1724.   {exit}{/irow2 irow2 1 add D}ie
  1725.  }loop
  1726. /printrow{
  1727.  /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D
  1728.  /xleft xoff xo add D
  1729.  /irow E D
  1730.  /cells rdesc irow get 6 get D
  1731.  0 1 ncol{
  1732.   /icol E D
  1733.   /cell cells icol get D
  1734.   cell 0 ne{
  1735.    cell aload pop /CB E D /cvsize E D /above E D /fontsz E D
  1736.    /DV E D /bot E D /top E D /right E D /left E D /nowrap E D /valign E D
  1737.    /dp E D /align E D /rspan E D /cspan E D /cclass E D /ctype E D /cmax E D
  1738.    /cmin E D /proc E D
  1739.    rspan 0 eq{/rspan nrow irow sub 1 add D}if
  1740.    cspan 0 eq{/cspan ncol icol sub 1 add D}if
  1741.    /width 0 D
  1742.    0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for
  1743.    /rhight rdesc irow get 0 get D
  1744.    /hight rhight D
  1745.    1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for
  1746.    /W xo xoff add width add right sub D
  1747.    /EO xo xoff add left add D SI
  1748.    Cf{
  1749.     gsave CB VC xo xoff add ycur yoff add M
  1750.     0 hight neg RL width 0 RL 0 hight RL width neg 0 RL fill
  1751.     grestore
  1752.    }if
  1753.    ctype 1 eq{() BD}if
  1754.    /A0 align D RC
  1755.    AT 4 eq{
  1756.     /DC dp D /ID 1 D /DO cdesc icol get 5 get D /Lo DO DV 0 get sub D /L1 Lo D
  1757.    }if
  1758.    valign 3 le{0 ycur yoff add top sub
  1759.     hight cvsize sub valign 1 sub mul 2 div sub M}
  1760.    {0 ycur yoff add top sub above add rdesc irow get 4 get sub M}ie
  1761.    /PA f D /BP t D /Fl t D
  1762.    BL proc exec BN
  1763.    /PA t D
  1764.    ctype 1 eq{() ES}if
  1765.   }if
  1766.   /xoff xoff cdesc icol get 0 get add D
  1767.  }for
  1768.  /yoff yoff rhight sub D
  1769. /printhead {0 1 nhead 1 sub{printrow}for} D
  1770. /printfoot {nhead 1 nhead nfoot add 1 sub{printrow}for} D
  1771. /Tf {
  1772.  OU{rules 2 ge{/yoff 0 D
  1773.    gsave 0 Sg
  1774.    [0 1 nhead 1 sub{}for rbeg 1 row 1 sub{}for nhead 1 nhead nfoot add 1 sub{}for]{
  1775.     /irow E D
  1776.     /xoff ll twidth PL 2 ge{Sf div}if sub talign mul 2 div D
  1777.     /cells rdesc irow get 6 get D
  1778.     0 1 ncol{
  1779.      /icol E D
  1780.      /cell cells icol get D
  1781.      cell 0 ne{
  1782.       /rspan cell 6 get D
  1783.       /cspan cell 5 get D
  1784.       rspan 0 eq{/rspan nrow irow sub 1 add D}if
  1785.       cspan 0 eq{/cspan ncol icol sub 1 add D}if
  1786.       /width 0 D
  1787.       0 1 cspan 1 sub{icol add cdesc E get 0 get /width E width add D}for
  1788.       /rhight rdesc irow get 0 get D
  1789.       /hight rhight D
  1790.       1 1 rspan 1 sub{irow add rdesc E get 0 get /hight E hight add D}for
  1791.       xo xoff add width add ycur yoff add M
  1792.       0 hight neg icol cspan add 1 sub ncol lt
  1793.        {cdesc icol 1 add get 4 get dup rules 3 le{1 eq}{pop t}ie
  1794.         {1 eq{0.8}{0.3}ie
  1795.         LW RL CP stroke M}{pop R}ie}{R}ie
  1796.       irow nhead nfoot add 1 sub ne nfoot 0 eq or
  1797.        {irow rspan add 1 sub nrow lt
  1798.        {rdesc irow rspan add get 3 get}{nfoot 0 eq{0}{1}ie}ie
  1799.        dup rules 2 mod 0 eq{1 eq}{pop t}ie
  1800.        {1 eq irow rspan add nhead eq or irow rspan add row eq nfoot 0 gt and or
  1801.         {0.8}{0.3}ie LW width neg 0 RL CP stroke M}{pop}ie}if
  1802.      }if
  1803.      /xoff xoff cdesc icol get 0 get add D
  1804.     }for
  1805.     /yoff yoff rhight sub D
  1806.    }forall
  1807.    grestore
  1808.    /Ms t D
  1809.   }if
  1810.   frame 1 gt{
  1811.    gsave
  1812.    1 LW 0 Sg
  1813.    xleft ycur M CP BB
  1814.    0 yoff frame 5 eq frame 7 ge or{RL}{R}ie
  1815.    twidth 0 frame 3 eq frame 4 eq or frame 8 ge or{RL}{R}ie CP BB
  1816.    0 yoff neg frame 6 ge{RL}{R}ie
  1817.    twidth neg 0 frame 2 eq frame 4 eq or frame 8 ge or{RL}{R}ie
  1818.    closepath stroke
  1819.    grestore
  1820.    /Ms t D
  1821.   }if
  1822. &openps if($opt_o);
  1823. $ntab=-1;
  1824. $tables="/tables [";
  1825. @docs=$#ARGV<0?("-"):@ARGV;
  1826. if($tocdoc) {$#docs=0};
  1827. for (@docs) {$levl{$_}=1};
  1828. $nref=0;
  1829. $nhd=0;
  1830. $nlnk=1;
  1831. $ndoc=0;
  1832. $nrem=0;
  1833. $toc="/BO 0 D TC /Ba f D Bs /AU f D /UR () D RC ZF\n";
  1834. $toc.="()F2" if(!$latin1);
  1835. $toc.="($toc{'heading'})WB\n" if(!$tocdoc);
  1836. $fl1="";
  1837. $fl2="";
  1838. $np="NP RC ZF";
  1839. $P3="";
  1840. while($html=shift @docs) {
  1841.   $ndoc++;
  1842.   $ba2="";
  1843.   $P2="(";
  1844.   $banner="";
  1845.   undef @links;
  1846.   $level=$levl{$html};
  1847.   if(&h2p) {
  1848.     if($ndoc==1) {
  1849.       $toc=~s/\$T/$ti/g;
  1850.       $toc=~s/\$A/$au/g;
  1851.       $toc=~s/[\200-\377]+/)F1($&)F2(/g if(!$latin1);
  1852.     }
  1853.     if($layer) {
  1854.       @docs=(@docs,@links);
  1855.     } else {
  1856.       @docs=(@links,@docs);
  1857.     }
  1858.     $rem=$#docs+1;
  1859.     if($rem && $opt_W) {
  1860.       &dbg("At least $rem document".($rem>1?"s":"")." remaining\n");
  1861.     }
  1862.     if($banner) {
  1863.       $_="/Ba t D /BA {($banner)BN} D\nBs f Pb CP /BO E D pop\n";
  1864.       &Subst($_);
  1865.       s/  H\(/ -1 H(/g;
  1866.     } else {
  1867.       $_="/Ba f D /BO 0 D Bs";
  1868.     }
  1869.     if($tocdoc && $first && $ndoc==1) {
  1870.       $TC=" TC";
  1871.       $et=" NP Ep ET /Tc f D";
  1872.     } else {
  1873.       $TC="";
  1874.       $et="";
  1875.     }
  1876.     $_.="\n/UR ($html) D\n/Ti ($ti) D\n/Au ($au) D\n/Df $draft D\n$TC\n";
  1877.     if(!$tocdoc) {
  1878.       $toc.="ND 1 gt{Ts 3 mul Np $refs{$html}()0 C()BD($ti)ES()$refs{$html}"
  1879.            ." 1 TN()EA()BN}if\n";
  1880.     }
  1881.     $hl=0;
  1882.     while($P2=~s/(\d) (\d)  H\(([^\s<)]*)/$1 $2 $nhd H($3)WB $nref Sn(/) {
  1883.       $nhd++;
  1884.       if($hl+1<$2) {
  1885.         for($hl+1..$2-1) {
  1886.           push(@z1,-$nref);
  1887.           push(@z2,$_);
  1888.         }
  1889.       }
  1890.       $hl=$2;
  1891.       $hind[$hl-1]++;
  1892.       for $i ($hl..5) {$hind[$i]=0};
  1893.       $hind=join('.',@hind[0..$hl-1]);
  1894.       $hst=$3;
  1895.       $'=~/\)EH/;
  1896.       ($htxt=$hst.$`)=~s/\)EA\(//g;
  1897.       if(!$tocdoc) {
  1898.         $toc.="$hl NH le{$nref($hind\\240\\240)$hl C($htxt)$nref 1 TN()EA()BN}if\n";
  1899.       }
  1900.       push(@z1,$nref);
  1901.       push(@z2,$hl);
  1902.       $nref++;
  1903.       $htxt=~s/(\s+|\)BR\()/ /g;
  1904.       $htxt=~s/(^\s+|\)[^(]*\(|\s+$)//g;
  1905.       $htxt="" if(!$latin1);
  1906.       $dh.="/h$nhd [($hind\\240\\240)($htxt)] D\n";
  1907.     }
  1908.     if($tocdoc) {
  1909.       if($ndoc==1 && !$first) {
  1910.         $toc="TC RC ZF $_ $P2 WB () BN\n";
  1911.         $P2="";
  1912.         $P3="";
  1913.         $np="";
  1914.         $_="";
  1915.       }
  1916.     }
  1917.     $P3.="$fl1\n/Cb $bg D /Ct $tcol D /Cl $lcol D /CL -1 D Ct Sc\n$fl2\n$_\n$np\n$P2";
  1918.     if($tocdoc && $ndoc==1 && !$first) {
  1919.       $np="/Cb $bg D NP RC ZF";
  1920.     } else {
  1921.       $fl1="WB NL$et";
  1922.       $fl2="DS";
  1923.       $np="0 BO R";
  1924.     }
  1925. $P3.=($P3!~/\)\s*$/?"()":"")."WB NL";
  1926. if(!$tocdoc && $first && $nhd){$P3="$toc/OU t D /Cb $bg D NP Ep ET $P3"};
  1927. if(!$first && ($tocdoc || !$tocdoc && $nhd)){$P3.=" $toc"};
  1928. if($ntab>=0) {
  1929.   $_="$tables] D";
  1930.   &ack($_);
  1931.   y/\t\f/ /;
  1932.   s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
  1933.   s/\)XX/)9 9 PR/g;
  1934.   s/  H\(/ -1 H(/g;
  1935.   $tables=$_;
  1936. $_="%!\n%%Title: $title\n$P0$P1";
  1937. if($nimg>=0) {
  1938.   $_.="/AX [".join(' ',@XS)."] D\n/AY [".join(' ',@YS)."] D\n"
  1939.      ."/IX [".join(' ',@IX)."] D\n/IT [".join(' ',@IT)."] D\n";
  1940.   if($nm>=0) {
  1941.     $_.="/AZ [".join(' ',@DP)."] D\n/WS [".join(' ',@WS)."] D\n"
  1942.        ."/FC [".join(' ',@FC)."] D\n/NI $nm D\n/BM ".($nm+1)." array D\nSB\n";
  1943.     for $i (0..$nm) {$_.="$BM[$i]\n\n"}
  1944.   $_.="\n$pv%Endpv\n" if($nps);
  1945. @kw=split(/[, ]+/,$kw);
  1946. @Kw=();
  1947. for $i (@kw){push(@Kw,$i) if(!grep(/^$i$/,@Kw))};
  1948. $kw=join(', ',@Kw);
  1949. for $i (0..$#z2) {
  1950.   $n=0;
  1951.   $j=$i;
  1952.   while($j++<=$#z2 && $z2[$j]>$z2[$i]) {$n++ if($z2[$j]==$z2[$i]+1)};
  1953.   push(@z3,$n);
  1954. $tdef=$ntab>=0?"$tbl$tables\n0 1 $ntab\{TS}for RC ZF\n":"";
  1955. $hd="/Hr [@z1]D\n/HV [@z2]D\n/Cn [@z3]D";
  1956. &cut($hd);
  1957. if($gd) {
  1958.   $sd="/Df t D /DG IW IW mul IL IL mul add sqrt D IW IL IW IL lt{E}if"
  1959.   ." /WM E D /WX E D /DZ 180 D gsave SD /DZ DZ DF mul D SD grestore\n";
  1960. } else {
  1961.   $sd="/Df f D\n";
  1962. $_.=<<EOD;
  1963. [/Creator ($version) /Author ($Au) /Keywords ($kw) /Subject ($su)
  1964.  /Title ($title) /DOCINFO pdfmark
  1965. /ND $ndoc D
  1966. /HN [1 1 $nref\{pop (??)}for] D
  1967. $dh$hd
  1968. Hr length 0 gt{[/PageMode /UseOutlines /DOCVIEW pdfmark}if
  1969. /Hn 1 D
  1970. 0 1 Hr length 1 sub{
  1971.  /Bn E D [Cn Bn get dup 0 gt{/Count E HV Bn get Bl ge{neg}if}{pop}ie
  1972.  /Dest Hr Bn get dup abs ST cvs cvn E 0 ge{(h)Hn ST cvs join cvx exec dup 1 get
  1973.  E Nf{0 get E join}{pop}ie /Hn Hn 1 add D}{()}ie /Title E /OUT pdfmark}for
  1974. ZF /FN Fp D Ps 0 FS /WC Wf{( )}{<A1A1>}ie SW pop D
  1975. ET RC ZF
  1976. $sd$rfs$tdef$P3
  1977. /TE t D NP TU PM 0 eq and{/Pn () D showpage}if end restore
  1978. if(($first || $opt_R) && $xref{'passes'}) {
  1979.   &dbg("Inserting cross references\n") if($opt_d);
  1980.   for $i (1..$xref{'passes'}) {&ref};
  1981. &fin;
  1982. sub h2p {
  1983.   if($html eq '-') {
  1984.     $_=<>;
  1985.   } elsif($html=~m|://|) {
  1986.     if(($prompt || $nrem>50) && $level>1) {
  1987.       &prompt("Retrieve document $html (y/n/q)? ",$ans);
  1988.       if($ans=~/q/i) {undef @docs};
  1989.       return 0 unless($ans=~/y/i);
  1990.     }
  1991.     &geturl($html,$_) || return;
  1992.     $nrem++;
  1993.     if($contyp!~m|text/html|i) {$_=" <plaintext>\n$_"};
  1994.     unless(($ba2)=$html=~m|(.*://.*/)|) {$ba2=$html."/"};
  1995.   } else {
  1996.     if(open(FILE,$html)) {
  1997.       &dbg("Reading $html\n") if($opt_W || $opt_d);
  1998.       $_=<FILE>;
  1999.       if(!/<HTML/i && $html!~/html?$/i && ($html!~/\.ps$/i || $ndoc>1)) {
  2000.         $_=" <plaintext>\n$_";
  2001.       }
  2002.       close FILE;
  2003.     } else {
  2004.       &dbg("*** Error opening $html\n");
  2005.       return 0;
  2006.     }
  2007.   if(/^%!/ && /$delim/) {
  2008.     $psin=1;
  2009.     &openps if($opt_o);
  2010.     $_=$P0.$';
  2011.     for $s ("b","c","cw","g","t") {
  2012.       &dbg("Option -$s ignored\n") if(eval "\$opt_$s");
  2013.     }
  2014.     &fin;
  2015.   &hb($_,$head);
  2016.   $head=~/<title$R\s*([\w\W]*)<\/title/i;
  2017.   ($ti=$2)=~s/\s+/ /g;
  2018.   $ti=$doctit{$html} if(!$ti);
  2019.   $ti=~s/\s*$//g;
  2020.   &spec($ti);
  2021.   &ent($ti);
  2022.   $ti="<Untitled>" if(!$ti);
  2023.   $title=$ti if(!$title);
  2024.   $draft="f" if(!$ddr);
  2025.   $au="";
  2026.   while($head=~/<meta\s[^>]*(name|http-equiv)\s*=\s*["']?\s*(\w+)$R/gi) {
  2027.     $k=$2;
  2028.     ($v)=$&=~/content\s*=\s*["']\s*([^"']+)/i;
  2029.     $v=~s/\s+/ /g;
  2030.     $v=~s/\s*$//g;
  2031.     &spec($v);
  2032.     &ent($v);
  2033.     if($k=~/author/i) {$au=$au?"$au, $v":$v};
  2034.     if($k=~/keywords/i) {$kw=$kw?"$kw, $v":$v};
  2035.     if($k=~/subject/i && !$su) {$su=$v};
  2036.     if(!$ddr && $k=~/status/i && $v=~/draft/i) {$draft="t";$gd=1};
  2037.   $Au.=($Au?" + ":"").$au if($au);
  2038.   $b2=$opt_b;
  2039.   unless($b2) {
  2040.     ($b2)=$head=~/<base\s+href\s*=\s*"([^"]*)"$R/i;
  2041.     unless($b2) {($b2)=$head=~/<base\s+href\s*=\s*([\w\.-]+)$R/i}
  2042.     unless($b2) {$b2=$ba2}
  2043.   $b2=~s|[^/]*$||;
  2044.   ($b1)=$b2=~m|(.*://[^/]*)/|;
  2045.   unless($b1) {$b1=$opt_r};
  2046.   unless($b2) {$b2=$html=~m|(.*/)[^/]*$|?$1:""};
  2047.   if(!defined $B2) {$B2=$b2};
  2048.   $levl{$b2.$html}=$levl{$html};
  2049.   while($link && $head=~/<link\s+[^>]*rel\s*=\s*["']?next$R/gi) {
  2050.     if(($lnk)=$&=~/href\s*=\s*["']?\s*([^"' >]*)/gi) {
  2051.       if($lnk=~m|.+//[^/]+$|) {$lnk=$&."/"}
  2052.       if($lnk=~m|://|) {
  2053.         $rlnk=0;
  2054.       } else {
  2055.         $rlnk=1;
  2056.         if($lnk=~m|^/|) {$lnk=$b1.$lnk} else {$lnk=$b2.$lnk}
  2057.       }
  2058.       while($lnk!~m|^\.\./| && $lnk=~m|[^/]*/\.\./|) {$lnk=$`.$'};
  2059.       $lnk=~s|/\./|/|g;
  2060.       if(&follow && !$levl{$lnk}) {
  2061.         $levl{$lnk}=$level+1;
  2062.         push(@links,$lnk);
  2063.       }
  2064.     }
  2065.   ($battr)=/<BODY$R/i;
  2066.   ($lang)=$battr=~/\slang\s*=\s*['"]?([a-zA-Z-]+)/i;
  2067.   ($lang)=$head=~/<html[^>]+lang\s*=\s*['"]?([a-zA-Z-]+)/i if(!$lang);
  2068.   $lang=$opt_l if($opt_l);
  2069.   $lang='en' if(!$lang);
  2070.   $lang=lc $lang;
  2071.   if($battr=~/\stext\s*=\s*['"]?\s*#?(\w+)/i) {$tcol=&col2rgb($1)};
  2072.   if(!$tcol) {$tcol="Dt"};
  2073.   if($battr=~/\slink\s*=\s*['"]?\s*#?(\w+)/i) {$lcol=&col2rgb($1)};
  2074.   if(!$lcol) {$lcol="Dl"};
  2075.   &inihyph if($opt_H);
  2076.   ($bg)=$battr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
  2077.   $bg=&col2rgb($bg);
  2078.   if($bg) {
  2079.     ($red,$grn,$blu)=@cvec;
  2080.   } else {
  2081.     ($red,$grn,$blu)=$bgcol=~/#(\w+).*#(\w+).*#(\w+)/;
  2082.     $bg="Db";
  2083.   $temp="";
  2084.   while(/<object$R/i) {
  2085.     $temp.=$`;
  2086.     $tag=$&;
  2087.     $end=$';
  2088.     $type=$tag=~/type\s*=\s*($S)/i?$+:"";
  2089.     $uaddr=$tag=~/data\s*=\s*($S)/i?$+:"";
  2090.     if($type=~/^text\/(html|plain)$/i
  2091.      || !$type && $uaddr=~m"(\.html?|://.+/|://[^/]+)$"i) {
  2092.       $tag=~/data\s*=\s*/i;
  2093.       if(&open($uaddr,$idoc)) {
  2094.         if($type=~/plain/i) {
  2095.           $idoc="<XMP>$idoc</XMP>";
  2096.         } else {
  2097.           &hb($idoc,$dum);
  2098.         }
  2099.         $_=$idoc;
  2100.         $_.=$' if($end=~/<\/object>/i);
  2101.       } else {
  2102.         &dbg("\n*** Error opening $uaddr\n");
  2103.         $_=$end;
  2104.       }
  2105.     } else {
  2106.       $temp.=$tag;
  2107.       $_=$end;
  2108.     }
  2109.   $_=$temp.$_;
  2110.   if($opt_c && defined $package{'check'}) {
  2111.     $file=$html;
  2112.     if($html=~m|://|) {
  2113.       open(SCRATCH,">$scr");
  2114.       print SCRATCH;
  2115.       close SCRATCH;
  2116.       $file="$scr";
  2117.     }
  2118.     &dbg(`$package{'check'} $file`);
  2119.   if(!$latin1) {
  2120.     if($opt_e=~/EUC-/i) {
  2121.       s/([\216\217\241-\376].)+/\000$&\000/g;
  2122.       &spec($_);
  2123.       s/\000(.+?)\000/)F1($1)F2(/g;
  2124.     } elsif($opt_e=~/SHIFT-JIS/i) {
  2125.       s/[\201-\237\340-\374][@-~\200-\374]/$&\000/g;
  2126.       s/[\241-\337]+(?!\000)/$&\000/g;
  2127.       s/[ -~\t\n\r\240]+(?!\000)/\002$&\001/g;
  2128.       &spec($_);
  2129.       s/\000//g;
  2130.     } else {
  2131.       while(/\e\$B([^\e]*)/) {
  2132.         $beg=$`;
  2133.         $end=$';
  2134.         $mat=$1;
  2135.         $mat=~s/\s//g;
  2136.         $_="$beg\001$mat$end";
  2137.       }
  2138.       s/\e\([BJ]/\002/g;
  2139.       &spec($_);
  2140.     }
  2141.     s/\001/)F1(/g;
  2142.     s/\002/)F2(/g;
  2143.     $_=")F2($_";
  2144.     y/\000-\010\013\016-\037\177//d;
  2145.   } else {
  2146.     &spec($_);
  2147.     y/\000-\010\013\016-\037\177-\237//d;
  2148.   s/(\r\n|\r)/\n/g;
  2149.   $refs{$html}=$nref++ if(!defined $refs{$html});
  2150.   $_="\004$lang\004)WB $refs{$html} Sn($_";
  2151. #  Yes, I know Perl has case-insensitive pattern matching. But on my system
  2152. #  it takes about 10 times longer to run!
  2153.   $pt="";
  2154.   if(/<[pP][lL][aA][iI][nN][tT][eE][xX][tT]$R/) {$_=$`;$pt=$'};
  2155.   while($_){
  2156.     if(/(<[lL][iI][sS][tT][iI][nN][gG]$R)/) {$_=$`; $tag=$1; $rest=$';
  2157.       if(/<[xX][mM][pP]$R/){$_=$`; &Subst($_); $P2.="$_)XX("; $_=$'.$tag.$rest;
  2158.         if(m|</[xX][mM][pP]$R|) {$P2.="$`)RP("; $_=$'}
  2159.         else {$P2.=$'; $_=""}}
  2160.       else {&Subst($_); $P2.="$_)XX("; $_=$rest;
  2161.         if(m|</[lL][iI][sS][tT][iI][nN][gG]$R|) {$P2.="$`)RP("; $_=$'}
  2162.         else {$P2.=$'; $_=""}}}
  2163.     elsif(/<[xX][mM][pP]$R/) {$_=$`; &Subst($_); $P2.="$_)XX("; $_=$';
  2164.       if(m|</[xX][mM][pP]$R|) {$P2.="$`)RP("; $_=$'}
  2165.       else {$P2.=$'; $_=""}}
  2166.     else {&Subst($_);$P2.=$_; $_=""}
  2167.   $pt=~s/\f/$pc/g;
  2168.   if($pt) {$P2.=")XX($pt"};
  2169.   $P2.=")";
  2170.   if($plain) {$P2.="RP ()"};
  2171.   while($P2=~/XX\(/) {
  2172.     $beg=$`;
  2173.     $'=~/\)(RP|$)/;
  2174.     $mat=$`;
  2175.     $end=$&.$';
  2176.     $mat=~s/(.*\n){30}.*/$&)WR(/g;
  2177.     ($temp=$mat)=~s/\)[^(]+\(//g;
  2178.     @prel=split(' *\n',$temp);
  2179.     $maxl=0;
  2180.     for $line (@prel) {
  2181.       $line=~s/\\.../x/g;
  2182.       while($line=~/\t+/) {
  2183.         $sp=' ' x (length($&)*8-length($`)%8);
  2184.         $line=~s/\t+/$sp/;
  2185.         $mat=~s/\t+/$sp/;
  2186.       }
  2187.       $ll=length($line);
  2188.       $maxl=$ll if($ll > $maxl);
  2189.     }
  2190.     $P2="$beg ".($#prel+1)." $maxl PR($mat$end";
  2191.   $P1=~s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
  2192.   $P2=~s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
  2193.   $P2=~y/\t\f/ /;
  2194. sub Subst{
  2195.   local($_)=@_;
  2196.   if($page_break) {
  2197.     s/<!--NewPage-->/$pc/g;
  2198.     s/<(\?|hr\s+class\s*=\s*["']?)\s*page-break$R/$pc/gi;
  2199.   s/<!--OddPage-->/)WB NL OP(/g;
  2200.   s/(­?|­?|<!--hy-->)/)HY(/g;
  2201.   while(/<!--/) {
  2202.     $_=$`;
  2203.     &getcom;
  2204.     $_.=$rest;
  2205.   $temp="";
  2206.   while(/<([^"'>]*=\s*["'])/) {
  2207.     $temp.=$`."<";
  2208.     $_=$1.$';
  2209.     while(/^[^"'>]*=\s*(["'])/) {
  2210.       $temp.=$&;
  2211.       $_=$';
  2212.       if(/$1/) {
  2213.         ($tg=$`)=~y/>/\003/;
  2214.         $temp.=$tg.$&;
  2215.         $_=$';
  2216.       }
  2217.     }
  2218.   $_=$temp.$_;
  2219.   $a='[aA][lL][iI][gG][nN]';
  2220.   $A="($a\\s*=\"?|[sS][tT][yY][lL][eE]\\s*=\\s*\"?[tT][eE][xX][tT]-\\s*$a:)";
  2221.   $I='[lL][eE][fF][tT]';
  2222.   $C='[cC][eE][nN][tT][eE][rR]';
  2223.   $D='[rR][iI][gG][hH][tT]';
  2224.   $J='[jJ][uU][sS][tT][iI][fF][yY]';
  2225.   $s='[sS][eE][lL][eE][cC][tT]';
  2226.   $F='[fF][oO][nN][tT]';
  2227.   $U='[cC][oO][lL][oO][rR]';
  2228.   s/<\w+[^>]*\s+[iI][dD]\s*=\s*($S)[^>]*>/$&<a name="$+">/g;
  2229.   s|<[dD][eE][lL]$R[\w\W]*?</[dD][eE][lL]>||g if($del{'display'}=~/^none$/);
  2230.   $ndiv=1;
  2231.   s|</?[dD][iI][vV]\d$R||g;
  2232.   s|<(/?)([dD][iI][vV])([>\s])|"<$1$2".($1?--$ndiv:$ndiv++).$3|eg;
  2233.   while(/<[dD][iI][vV](\d+)$R/) {
  2234.     $dbeg=$`;
  2235.     $dnum=$1;
  2236.     $dattr=$2;
  2237.     $dend=$';
  2238.     $div="";
  2239.     $ediv="";
  2240.     if($2=~/class\s*=\s*["']?noprint$R/i) {
  2241.       $_=$dbeg;
  2242.       $_.=$' if($dend=~/<\/[dD][iI][vV]$dnum>/);
  2243.     } else {
  2244.       if($dattr=~/$A\s*($I|$C|$D|$J)/) {
  2245.         $div.=")".$algn{"\L$2"}." Al(";
  2246.         $ediv.=")Ea(";
  2247.       }
  2248.       if($dattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i) {
  2249.         $lang=lc $1;
  2250.         $div.="\004$lang\004";
  2251.         &inihyph if($opt_H);
  2252.         $dbeg=~/(\004[^\004]*\004)[^\004]*$/;
  2253.         $ediv.=$1;
  2254.       }
  2255.       $dend=~s|</[dD][iI][vV]$dnum>|$ediv)BR(|;
  2256.       $_="$dbeg$div)BR($dend";
  2257.     }
  2258.   s|<$C$R|)2 Al(|g;
  2259.   s|</$C$R|)Ea(|g;
  2260.   s|<(\w+)/([^/]+)/|<$1>$2</$1>|g;
  2261.   s/(<\w+[^>]*>)\n|\n(<\/\w+>)/$+/g;
  2262.   s|(<[lL][iI])$R\s*<[pP]>|)0 P($1$2|g;
  2263.   s/<[hH]([1-6])\s+$A\s*($I|$C|$D|$J)$R/)$algn{"\L$3"} $1  H(/g;
  2264.   s|<[hH]([1-6])$R|)0 $1  H(|g;
  2265.   s|</[hH][1-6]>|)EH(|g;
  2266.   s|<[bB][rR]$R|)BR(|g;
  2267.   s/<[pP]\s+[^>]*$A\s*($I|$C|$D|$J)$R/)$algn{"\L$2"} P(/g;
  2268.   s|<[pP]$R|)0 P(|g;
  2269.   s|</[pP]>|)EP(|g;
  2270.   s|<[aA][dD][dD][rR][eE][sS][sS]$R|)AD(|g;
  2271.   s|</[aA][dD][dD][rR][eE][sS][sS]>|)DA(|g;
  2272.   s|<[pP][rR][eE]$R\n?|)XX(|g;
  2273.   s|\n? *</[pP][rR][eE]>|)RP(|g;
  2274.   s|<[dD][tT]$R|)DT(|g;
  2275.   s|<[dD][dD]$R|)DD(|g;
  2276.   s|<[dD][lL]\s[^>]*[cC][oO][mM][pP][aA][cC][tT]$R|)1 DL(|g;
  2277.   s|<[dD][lL]$R|)0 DL(|g;
  2278.   s|</[dD][lL]>|)LD(|g;
  2279.   s|<[uU][lL]$R|)UL(|g;
  2280.   s|</[uU][lL]>|)LU(|g;
  2281.   s|<[mM][eE][nN][uU]$R|)UL(|g;
  2282.   s|</[mM][eE][nN][uU]>|)LU(|g;
  2283.   s|<[dD][iI][rR]$R|)UL(|g;
  2284.   s|</[dD][iI][rR]>|)LU(|g;
  2285.   s|<[oO][lL]\s[^>]*[sS][tT][aA][rR][tT]\s*=\s*['"]?(-?\d+)$R|$&)WB $1 Ln(|g;
  2286.   s|<[oO][lL]\s[^>]*[tT][yY][pP][eE]\s*=\s*['"]?([1iIaA])$R|)$lity{$1} OL(|g;
  2287.   s|<[oO][lL]$R|)4 OL(|g;
  2288.   s|</[oO][lL]>|)LO(|g;
  2289.   s|<[lL][iI]\s[^>]*[vV][aA][lL][uU][eE]\s*=\s*['"]?(-?\d+)$R|$&)WB $1 Ln(|g;
  2290.   s|<[lL][iI]\s[^>]*[tT][yY][pP][eE]\s*=\s*['"]?($ltr)$R|)$lity{$1} LI(|g;
  2291.   s|<[lL][iI]$R|)-1 LI(|g;
  2292.   s|</[lL][iI]$R||g;
  2293.   s"<([bB][qQ]|[bB][lL][oO][cC][kK][qQ][uU][oO][tT][eE])$R")BQ("g;
  2294.   s"</([bB][qQ]|[bB][lL][oO][cC][kK][qQ][uU][oO][tT][eE])>")QB("g;
  2295.   s|<[sS][tT][rR][oO][nN][gG]$R|)BD(|g;
  2296.   s|</[sS][tT][rR][oO][nN][gG]>|)ES(|g;
  2297.   s|<[sS][aA][mM][pP]$R|)SM(|g;
  2298.   s|</[sS][aA][mM][pP]>|)ES(|g;
  2299.   s|<[qQ]$R(\s*)|$2)Q(|g;
  2300.   s|(\s*)</[qQ]>|)EQ($1|g;
  2301.   s|<[cC][iI][tT][eE]$R|)CT(|g;
  2302.   s|</[cC][iI][tT][eE]>|)ES(|g;
  2303.   s|<[vV][aA][rR]$R|)I(|g;
  2304.   s|</[vV][aA][rR]>|)ES(|g;
  2305.   s|<[bB]$R|)BD(|g;
  2306.   s|</[bB]>|)ES(|g;
  2307.   s|<[iI]$R|)I(|g;
  2308.   s|</[iI]>|)ES(|g;
  2309.   s|<[tT][tT]$R|)TT(|g;
  2310.   s|</[tT][tT]>|)ES(|g;
  2311.   s|<[uU]$R|)UN(|g;
  2312.   s|</[uU]>|)NU(|g;
  2313.   s|<[sS]([tT][rR][iI][kK][eE])?$R|)SE(|g;
  2314.   s|</[sS]([tT][rR][iI][kK][eE])?>|)XE(|g;
  2315.   s|<[dD][fF][nN]$R|)I(|g;
  2316.   s|</[dD][fF][nN]>|)ES(|g;
  2317.   s|<[eE][mM]$R|)EM(|g;
  2318.   s|</[eE][mM]>|)ES(|g;
  2319.   s|<[cC][oO][dD][eE]$R|)SM(|g;
  2320.   s|</[cC][oO][dD][eE]>|)ES(|g;
  2321.   s|<[kK][bB][dD]$R|)KB(|g;
  2322.   s|</[kK][bB][dD]>|)ES(|g;
  2323.   s|<[bB][iI][gG]$R|)4 FZ(|g;
  2324.   s|</[bB][iI][gG]>|)ES(|g;
  2325.   s|<[sS][mM][aA][lL][lL]$R|)2 FZ(|g;
  2326.   s|</[sS][mM][aA][lL][lL]>|)ES(|g;
  2327.   s|<[iI][nN][sS]$R|)sM WB(|g;
  2328.   s|</[iI][nN][sS]>|)WB eM(|g;
  2329.   s|<[dD][eE][lL]$R|)sM $lt(|g;
  2330.   s|</[dD][eE][lL]>|)XE eM(|g;
  2331.   s|<[aA][cC][rR][oO][nN][yY][mM][^>]+[tT][iI][tT][lL][eE]\s*=\s*($S)[^>]*>|)($+)Ac(|g;
  2332.   s|</[aA][cC][rR][oO][nN][yY][mM]>|)Ca(|g;
  2333.   s|<[fF][oO][rR][mM][\w\W]*?</[fF][oO][rR][mM]>||g if(!$forms);
  2334.   s|</?[fF][oO][rR][mM]$R|)Ts BE(|g;
  2335.   s/<$s[^>]*[mM][uU][lL][tT][iI][pP][lL][eE]$R/)1 MS(<table>/g;
  2336.   s/<$s$R/)0 MS(<table>/g;
  2337.   s|</$s>|</table>|g;
  2338.   s/<[oO][pP][tT][iI][oO][nN]$R/<tr><td>)O(/g;
  2339.   while(/<[iI][nN][pP][uU][tT]$R/) {
  2340.     $beg=$`;
  2341.     $iattr=$1;
  2342.     $rest=$';
  2343.     $it=2;
  2344.     if($iattr=~/type\s*=\s*["']?(\w+)/i) {$it=$it{"\L$1"}};
  2345.     $siz=$iattr=~/size\s*=\s*["']?(\d+)/i?$1:12;
  2346.     $it="$siz $it" if($it==2);
  2347.     if(defined($it)) {
  2348.       $cmd=$it==3?"<img $iattr":")$it BX(";
  2349.     } else {
  2350.       $cmd="";
  2351.     }
  2352.     $_=$beg.$cmd.$rest;
  2353.   while(/<[tT][eE][xX][tT][aA][rR][eE][aA]$R/) {
  2354.     $beg=$`;
  2355.     $txatr=$1;
  2356.     $rest=$';
  2357.     if($rest=~m|</[tT][eE][xX][tT][aA][rR][eE][aA]>|) {
  2358.       $rest=$';
  2359.       $data=$textarea_data?$`:"";
  2360.       $rows=4;
  2361.       $cols=20;
  2362.       if($txatr=~/rows\s*=\s*["']?(\d+)/i) {$rows=$1};
  2363.       if($txatr=~/cols\s*=\s*["']?(\d+)/i) {$cols=$1};
  2364.       $nl=$data=~y/\n/\n/;
  2365.       for ($nl..$rows) {$data.="\n"};
  2366.       $data=~/(.*\n){$rows}/;
  2367.       ($data=$&)=~s/.*\n/<tr height=24><td valign=top>)0 FZ($&)ES(/g;
  2368.       $wi=10*$cols;
  2369.       $_="$beg<table border width=$wi cellpadding=2>$data</table>$rest";
  2370.     } else {
  2371.       $_=$beg.$rest;
  2372.     }
  2373.   $nfnt=1;
  2374.   s|<(/?)($F)([>\s])|"<$1$2".($1?--$nfnt:$nfnt++).$3|eg;
  2375.   while(/<$F(\d+)([^>]*)$U\s*=\s*["']?\s*#?(\w+)$R/) {
  2376.     $rgb=&col2rgb($3);
  2377.     $_=$`.($rgb?")WB $rgb Sc(":"")."<font$2$4";
  2378.     $temp=$';
  2379.     $temp=~s|</$F$1>|</font>)Ec(| if($rgb);
  2380.     $_.=$temp;
  2381.   $base{"+"}="Bf add ";
  2382.   $base{"-"}="Bf add ";
  2383.   s/<$F\d*\s[^>]*[sS][iI][zZ][eE]\s*=\s*["']?([+-]?)(\d+\.?\d*)$R/)$1$2 $base{$1}FZ(/g;
  2384.   s|<$F\d*$R|)3 FZ(|g;
  2385.   s|</$F\d*>|)Ef(|g;
  2386.   s|<[bB][aA][sS][eE]$F\s[^>]*[sS][iI][zZ][eE]\s*=\s*["']?(\d+)$R|)$1 BZ(|g;
  2387.   while(/(<[aA]\s+[^>]*)[nN][aA][mM][eE]\s*=\s*(["']?)([^"'\s>]*)$R([^\s<)]*)/) {
  2388.     $lnk="$html#$3";
  2389.     $refs{$lnk}=$nref++ unless(defined $refs{$lnk});
  2390.     $_="$`$1$4$5)WB $refs{$lnk} Sn($'";
  2391.   while(/<[aA]\s+[^>]*[hH][rR][eE][fF]\s*=\s*["']?\s*([^"'\s>]*)$R/) {
  2392.     $beg=$`;
  2393.     $tag=$&;
  2394.     $rest=$';
  2395.     $lnk=$1;
  2396.     $revtoc=$tag=~/rev\s*=['"]?\s*toc/i;
  2397.     $html=~m|[^/]*$|;
  2398.     $lnk=~s/^$&#/#/;
  2399.     $loc=$lnk=~/^#/;
  2400.     if($loc) {
  2401.       $html=~m|[^/]*$|;
  2402.       $lnk=$&.$lnk;
  2403.     }
  2404.     if($lnk=~m|.+//[^/]+$|) {$lnk=$&."/"}
  2405.     if($lnk=~m|://|) {
  2406.       $rlnk=0;
  2407.     } else {
  2408.       $rlnk=1;
  2409.       if($lnk=~m|^/|) {$lnk=$b1.$lnk} elsif($lnk!~m|^\w+:|) {$lnk=$b2.$lnk};
  2410.     }
  2411.     while($lnk!~m|^\.\./| && $lnk=~m|[^/]*/\.\./|) {$lnk=$`.$'};
  2412.     $lnk=~s"(^|/)\./"$1"g;
  2413.     ($doc)=$lnk=~/([^#]*)/;
  2414.     ($doctit{$doc})=$tag=~/title\s*=['"]([^'"]*)['"]/i;
  2415.     $T=0;
  2416.     $anch=2;
  2417.     if($loc || $opt_W && !$link && $level<=$maxlev && &follow){
  2418.       $refs{$lnk}=$nref++ unless(defined $refs{$lnk});
  2419.       $anch="$refs{$lnk} 1";
  2420.       $ltype=$rev && $revtoc && $ndoc==1 || $opt_C=~/f/ && $ndoc==1?1:0;
  2421.       $rest=~s|</a>|)$refs{$lnk} $ltype TN TL()Ec /AF f D(|i;
  2422.       if(&follow && !$levl{$doc}) {
  2423.         &dbg("Link: $doc\n") if($opt_d);
  2424.         $levl{$doc}=$level+1;
  2425.         push(@links,$doc);
  2426.       }
  2427.     } elsif(defined $refs{$lnk} || grep(/^$doc$/,(@docs,@links))) {
  2428.       $refs{$lnk}=$nref++ unless(defined $refs{$lnk});
  2429.       $anch="$refs{$lnk} 1";
  2430.     }
  2431.     $addr=$dum{$lnk}?"R$dum{$lnk}":0;
  2432.     if(!$dum{$lnk} && $lnk=~m|://|) {
  2433.       $dum{$lnk}=$nlnk++;
  2434.       $rfs.="/R$dum{$lnk} ($lnk) D\n";
  2435.       $addr="R$dum{$lnk}";
  2436.     }
  2437.     $_=$beg.")$addr $anch A(".$rest;
  2438.   s|</[aA]>|)EA(|g;
  2439.   if((!$mult || $doc_sep eq $pc && $mult)
  2440.    && m|<[bB][aA][nN][nN][eE][rR]$R([\w\W]*)</[bB][aA][nN][nN][eE][rR]>|) {
  2441.     $banner=$2;
  2442.     $_=$`.$';
  2443.   while(/<[tT][aA][bB][lL][eE]([^>]*)>/) {
  2444.     local($beg)=$`;
  2445.     local($rest)=$';
  2446.     $tattr=$1;
  2447.     $tag=$&;
  2448.     $rest=~/(<\/[tT][aA][bB][lL][eE]>|$)/;
  2449.     $table=$`;
  2450.     $rest=$';
  2451.     while($table=~/<[tT][aA][bB][lL][eE]([^>]*)>/) {
  2452.       $tattr=$1;
  2453.       $table=$';
  2454.       $beg.=$tag.$`;
  2455.       $tag=$&;
  2456.     }
  2457.     ($tla)=$tattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i;
  2458.     if(!$tla) {($tla)=$beg=~/\004_?([^\004]*)\004[^\004]*$/};
  2459.     $ntab++;
  2460.     $table=~s/^\s*//;
  2461.     undef %cells;
  2462.     undef %rd;
  2463.     undef @cali;
  2464.     undef @cval;
  2465.     undef @cgrp;
  2466.     undef @cwid;
  2467.     undef @codc;
  2468.     undef @r0;
  2469.     undef @c0;
  2470.     ($capat,$cap)=$table=~m|<caption$R([\w\W]*)</caption>|i;
  2471.     $capat=~/ALIGN\s*=\s*["']?\s*(\w+)/i;
  2472.     $capa=0;
  2473.     $capa=1 if("\L$1" eq "bottom");
  2474.     $capa=-1 if($cap!~/\S/);
  2475.     $bord=0;
  2476.     if($tattr=~/border/i) {
  2477.       ($bord)=$'=~/^\s*=\s*["']?(\d+)/;
  2478.       if(!$bord && $bord ne "0") {$bord=1};
  2479.     }
  2480.     ($talgn)=$tattr=~/ALIGN\s*=\s*["']?\s*(\w+)/i;
  2481.     $tal=-1;
  2482.     $tal=0 if($talgn=~/^left$/i);
  2483.     $tal=1 if($talgn=~/^center$/i);
  2484.     $tal=2 if($talgn=~/^right$/i);
  2485.     ($fra)=$tattr=~/FRAME\s*=\s*["']?\s*(\w+)/i;
  2486.     if($fra && $f{"\L$fra"}) {$fra=$f{"\L$fra"}} else {$fra=$bord?9:1};
  2487.     ($rul)=$tattr=~/RULES\s*=\s*["']?\s*(\w+)/i;
  2488.     if($rul && $r{"\L$rul"}) {$rul=$r{"\L$rul"}} else {$rul=$bord?5:1};
  2489.     unless(($twid)=$tattr=~/WIDTH\s*=\s*["']?(\d+\.?\d*%?)/i) {$twid=0};
  2490.     $twid=$twid=~/%$/?$`/100:-$twid;
  2491.     ($cpad)=$tattr=~/CELLPADDING\s*=\s*["']?\s*$V/i;
  2492.     if($tattr=~/CELLSPACING\s*=\s*["']?\s*$V/i && $1!=0) {$cpad+=$1/2};
  2493.     ($tbg)=$tattr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
  2494.     $tbg=&col2rgb($tbg);
  2495.     ($tcl)=$tattr=~/CLASS\s*=\s*["']?\s*(\w+)/i;
  2496.     $tcl="\L$tcl" eq "telelista"? 1: 0;
  2497.     $ic=0;
  2498.     $span=1;
  2499.     undef $gal;
  2500.     undef $gva;
  2501.     undef $odc;
  2502.     undef $gwi;
  2503.     $cgs=0;
  2504.     while($table=~/<[cC][oO][lL]([^>]*>)/g && $span>0) {
  2505.       $cola=$1;
  2506.       $ab=$`;
  2507.       $aft=$';
  2508.       $cola=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i;
  2509.       $alg=$algn{"\L$2"};
  2510.       ($val)=$cola=~/VALIGN\s*=\s*["']?\s*(\w+)/i;
  2511.       $val=$v{"\L$val"};
  2512.       ($odc)=$cola=~/CHAR\s*=\s*["']?(.)/i;
  2513.       unless(($wid)=$cola=~/WIDTH\s*=\s*["'](\d+%?)/i) {$wid=0};
  2514.       if($wid=~/%$/) {$wid=$`/100};
  2515.       ($span)=$cola=~/SPAN\s*=\s*["']?\s*(\d+)/i;
  2516.       if(!$span && $span ne "0") {$span=1};
  2517.       $us=1;
  2518.       if($cola=~/^GROUP/i) {
  2519.         $gal=$alg;
  2520.         $gva=$val;
  2521.         $gdc=$odc;
  2522.         $gwi=$wid;
  2523.         $cgs=1;
  2524.         if($aft=~/<COL\s/i) {
  2525.           $us=$`=~m|</?COLGROUP|i;
  2526.         }
  2527.       } else {
  2528.         while($ab=~/<COLGROUP/i) {$ab=$'};
  2529.         if($ab=~m|</COLGROUP|i) {
  2530.           undef $gal;
  2531.           undef $gva;
  2532.           undef $odc;
  2533.           undef $gwi;
  2534.         }
  2535.         if(!$alg) {$alg=$gal};
  2536.         if(!$val) {$val=$gva};
  2537.         if(!$odc) {$odc=$gdc};
  2538.         if(!$wid) {$wid=$gwi};
  2539.         if($span eq "0") {
  2540.           $ic++;
  2541.           push(@cali,$alg);
  2542.           push(@cval,$val);
  2543.           push(@cwid,$wid);
  2544.           push(@codc,$odc);
  2545.           push(@cgrp,1);
  2546.         }
  2547.       }
  2548.       if($us) {
  2549.         for (1..$span) {
  2550.           $ic++;
  2551.           push(@cali,$alg);
  2552.           push(@cval,$val);
  2553.           push(@cwid,$wid);
  2554.           push(@codc,$odc);
  2555.           push(@cgrp,$cgs);
  2556.           $cgs=0;
  2557.         }
  2558.       }
  2559.     }
  2560.     $table=~/<t[hd][\s>]/i;
  2561.     if($`!~/<tr/i) {$table="<TR>$table"};
  2562.     $nrow=-1;
  2563.     $ncol=-1;
  2564.     $nhead=0;
  2565.     $nfoot=0;
  2566.     $nb=0;
  2567.     unless($table=~/<tbody$R/i || $table=~s|</tfoot>|$&<tbody>|i) {
  2568.       $table=~s|</thead>|$&<tbody>|i;
  2569.     }
  2570.     while($table=~/<[tT][rR]\s*([^>]*)>/g) {
  2571.       $nrow++;
  2572.       $ab=$`;
  2573.       $row=$';
  2574.       $rattr=$1;
  2575.       for $j (@c0) {
  2576.         $cells{"$nrow,$j,0"}=1;
  2577.       }
  2578.       $rgrp=0;
  2579.       if($ab=~/<tbody$R/i) {
  2580.         $ib=0;
  2581.         while($ab=~/<[tT][bB][oO][dD][yY]$R/g) {
  2582.           $ib++;
  2583.           $battr=$1;
  2584.           if($ib>$nb) {
  2585.             $rgrp=1;
  2586.             $nb=$ib;
  2587.           }
  2588.         }
  2589.       } else {
  2590.         if($ab=~/<tfoot$R/i) {
  2591.           $nfoot++;
  2592.           $battr=$1;
  2593.         } elsif($ab=~/<thead$R/i) {
  2594.           $nhead++;
  2595.           $battr=$1;
  2596.         }
  2597.       }
  2598.       $battr=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i;
  2599.       $balgn=$algn{"\L$2"};
  2600.       $battr=~/VALIGN\s*=\s*["']?\s*(\w+)/i;
  2601.       $bva=$v{"\L$1"};
  2602.       ($bdc)=$battr=~/CHAR\s*=\s*["']?(.)/i;
  2603.       $rd{"$nrow,0"}=0;
  2604.       $rd{"$nrow,1"}=0;
  2605.       $rd{"$nrow,2"}=0 unless($rd{"$nrow,2"});
  2606.       $rd{"$nrow,3"}=$rgrp;
  2607.       $rattr=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i;
  2608.       $ralgn=$algn{"\L$2"};
  2609.       $rattr=~/VALIGN\s*=\s*["']?\s*(\w+)/i;
  2610.       $rva=$v{"\L$1"};
  2611.       ($rla[$nrow])=$rattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i;
  2612.       ($rbg)=$rattr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
  2613.       $rbg[$nrow]=&col2rgb($rbg);
  2614.       ($rdc)=$rattr=~/CHAR\s*=\s*["']?(.)/i;
  2615.       if($row=~/<tr/i) {$row=$`};
  2616.       $rh[$nrow]=$rattr=~/HEIGHT\s*=\s*["']?(\d+)/i?$1:0;
  2617.       $icol=0;
  2618.       $colsp=1;
  2619.       while($row=~/<[tT]([hH]|[dD])(\s*[^>]*)>/g && $colsp>0) {
  2620.         $cattr=$2;
  2621.         $cell=$';
  2622.         $ctype=$1=~/h/i?1:0;
  2623.         if($cell=~/<t[hd]/i) {$cell=$`};
  2624.         $cell=~s/\s+$//;
  2625.         $cell=~s/\)HY\($/\255/;
  2626.         $cell=~s/[\200-\377]([^\\]|\\20.)/$&)WB(/g if(!$latin1);
  2627.         ($rowsp)=$cattr=~/ROWSPAN\s*=\s*["']?(\d+)/i;
  2628.         $rsp=$rowsp;
  2629.         if(!$rsp) {
  2630.           if($rsp eq "0") {
  2631.             push(@c0,$icol);
  2632.           } else {
  2633.             $rowsp=1;
  2634.           }
  2635.           $rsp=1;
  2636.         }
  2637.         ($colsp)=$cattr=~/COLSPAN\s*=\s*["']?(\d+)/i;
  2638.         $csp=$colsp;
  2639.         if(!$csp) {
  2640.           if($csp eq "0") {
  2641.             push(@r0,$nrow);
  2642.             $csp=$ncol-$icol<0? 1: $ncol-$icol+1;
  2643.           } else {
  2644.             $colsp=1;
  2645.             $csp=1;
  2646.           }
  2647.         }
  2648.         ($cdc)=$cattr=~/CHAR\s*=\s*["']?(.)/i;
  2649.         while($cells{"$nrow,$icol,0"}==1) {$icol++};
  2650.         for $i ($nrow..$nrow+$rsp-2) {$rd{"$i,2"}=1};
  2651.         for $j ($icol..$icol+$csp-1) {
  2652.           for $i ($nrow..$nrow+$rsp-1) {
  2653.             $cells{"$i,$j,0"}=1;
  2654.           }
  2655.         }
  2656.         if($colsp) {
  2657.           for $j ($ncol+1..$icol+$csp) {
  2658.             for $i (@r0) {
  2659.               $cells{"$i,$j,0"}=1;
  2660.             }
  2661.           }
  2662.         }
  2663.         if($ic<$icol+$csp) {
  2664.           for ($ic..$icol+$csp-1) {
  2665.             push(@cali,$cali[$ic-1]);
  2666.             push(@cval,$cval[$ic-1]);
  2667.             push(@cgrp,0);
  2668.           }
  2669.           $ic=$icol+$csp;
  2670.         }
  2671.         $cal=$ctype;
  2672.         $cal=$balgn-1 if($balgn);
  2673.         $cal=$ralgn-1 if($ralgn);
  2674.         $cal=$cali[$icol]-1 if($cali[$icol]);
  2675.         if($cattr=~/(^|\s)ALIGN\s*=\s*["']?\s*(\w+)/i) {
  2676.           $cal=$algn{"\L$2"}-1 if($algn{"\L$2"});
  2677.         }
  2678.         $cvl=2;
  2679.         $cvl=$cval[$icol] if($cval[$icol]);
  2680.         $cvl=$bva if($bva);
  2681.         $cvl=$rva if($rva);
  2682.         if($cattr=~/VALIGN\s*=\s*["']?\s*(\w+)/i) {
  2683.           $cvl=$v{"\L$1"} if($v{"\L$1"});
  2684.         }
  2685.         ($cbg)=$cattr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
  2686.         $cbg=&col2rgb($cbg);
  2687.         for($rbg[$nrow],$tbg,$deftbg,$bg) {$cbg=$_ if(!$cbg)};
  2688.         $now=0;
  2689.         if($cattr=~/NOWRAP/i || $cal==4) {$now=1};
  2690.         $dc=".";
  2691.         $dc=$bdc if($bdc || $bdc eq "0");
  2692.         $dc=$rdc if($rdc || $rdc eq "0");
  2693.         $dc=$codc[$icol] if($codc[$icol] || $codc[$icol] eq "0");
  2694.         $dc=$cdc if($cdc || $cdc eq "0");
  2695.         ($wid)=$cattr=~/WIDTH\s*=\s*["'](\d+%)/i;
  2696.         if($wid=~/%$/) {$wid=$`/100};
  2697.         if($wid>$cwid[$icol]) {$cwid[$icol]=$wid};
  2698.         if($cpad || $cpad eq "0") {
  2699.           $clm=$cpad;
  2700.           $crm=$cpad;
  2701.           $ctm=$cpad;
  2702.           $cbm=$cpad;
  2703.         } else {
  2704.           $clm=$rul<5?8:4;
  2705.           $crm=$rul<5?8:4;
  2706.           $ctm=2;
  2707.           $cbm=6;
  2708.         }
  2709.         if($tcl==1) {
  2710.           $clm=$icol>0?12:2;
  2711.           $crm=12;
  2712.           $ctm=0;
  2713.           $cbm=0;
  2714.         }
  2715.         if($rul==1 && $fra==1 && $icol==0 && $tal==0) {$clm=0};
  2716.         ($lang)=$cattr=~/lang\s*=\s*["']?([a-zA-Z-]+)/i;
  2717.         for($rla[$nrow],$tla) {$lang=$_ if(!$lang)};
  2718.         $lang=lc $lang;
  2719.         &inihyph if($opt_H);
  2720.         $cbg=~/#(\w+).*#(\w+).*#(\w+)/;
  2721.         &img($cell,$1,$2,$3);
  2722.         @cll=("{(\004$lang\004)WB($cell)}",0,0,$ctype,0,$colsp,$rowsp,$cal,
  2723.          "($dc)",$cvl,$now,$clm,$crm,$ctm,$cbm,0,0,0,0,$cbg);
  2724.         for $i (0..$#cll) {$cells{"$nrow,$icol,$i"}=$cll[$i]};
  2725.         $icol+=$csp;
  2726.         if($icol-1>$ncol) {$ncol=$icol-1};
  2727.       }
  2728.     }
  2729.     for $j (0..$ncol) {
  2730.       for $i (0..$nrow) {
  2731.         if($cells{"$i,$j,0"} && $cells{"$i,$j,0"}!=1) {
  2732.           if($cells{"$i,$j,6"}>$nrow-$i+1) {$cells{"$i,$j,6"}=$nrow-$i+1};
  2733.           if($cells{"$i,$j,6"}>1) {$rd{"$i,2"}=1};
  2734.         }
  2735.       }
  2736.     }
  2737.     $rd{"$nrow,2"}=0;
  2738.     $rw="[";
  2739.     for $i (0..$nrow) {
  2740.       $rw.="[$rh[$i] ".$rd{"$i,1"}." ".$rd{"$i,2"}." ".$rd{"$i,3"}." 0 0 [";
  2741.       for $j (0..$ncol) {
  2742.         $cbg="";
  2743.         for($rbg[$i],$tbg,$deftbg,$bg) {$cbg=$_ if(!$cbg)};
  2744.         $temp="[{()} 0 0 0 0 1 1 0 (.) 0 0 $clm $crm $ctm $cbm 0 0 0 0 $cbg]";
  2745.         if($cells{"$i,$j,0"}==1) {
  2746.           $temp="0";
  2747.         } elsif($cells{"$i,$j,0"}) {
  2748.           $temp="[";
  2749.           for $k (0..$#cll) {
  2750.             $temp.=$cells{"$i,$j,$k"}." ";
  2751.           }
  2752.           $temp.="]";
  2753.         }
  2754.         $rw.="$temp\n";
  2755.       }
  2756.       $rw.="]]\n";
  2757.     }
  2758.     if($nrow==$nhead+$nfoot-1) {
  2759.       $nhead=0;
  2760.       $nfoot=0;
  2761.     }
  2762.     $tdesc="[0 0 $tcl 0 0 $tal 0 $twid $bord $nrow $ncol"
  2763.            ." $nhead $nfoot $fra $rul {($cap)} $capa]\n";
  2764.     $cdesc="[";
  2765.     for (0..$ncol) {
  2766.       unless($wid=$cwid[$_]) {$wid=0};
  2767.       $cdesc.="[0 0 0 $wid $cgrp[$_] 0 0]";
  2768.     }
  2769.     $cdesc.="]\n";
  2770.     $tables.="[$tdesc $cdesc $rw]]\n";
  2771.     $_=$beg.")$ntab PT(".$rest;
  2772.   &img($_,$red,$grn,$blu);
  2773.   &ack($_);
  2774.   $_[0]=$_;
  2775. sub getcom{
  2776.   $com=$&;
  2777.   $'=~/--\s*(--|>)/;
  2778.   $com.=$`.$&;
  2779.   $rest=$';
  2780.   while($1 eq "--") {
  2781.     if($'!~/--\s*(--|>)/) {$'=~/(>)/};
  2782.     $com.=$`.$&;
  2783.     $rest=$';
  2784. sub getl {
  2785.   ($l)=@_;
  2786.   if(!$lid{$l}) {
  2787.     while($l=~s/-[^-]+$// && !$lid{$l}) {};
  2788.   $lid{$l};
  2789. sub ack {
  2790.   local($_)=@_;
  2791.   chdir $tempdir;
  2792.   while (/<[mM][aA][tT][hH]/) {
  2793.     $beg=$`;
  2794.     $rest=$&.$';
  2795.     $rest=~m|</[mM][aA][tT][hH]>|;
  2796.     $end=$';
  2797.     $math=$`;
  2798.     if(&math2sym($math)) {
  2799.       $_=$beg.$sym.$end;
  2800.     } elsif($package{'TeX'} && $package{'dvips'}) {
  2801.       $math=~s|\\200|\\|g;
  2802.       $math=~s|\\201|\(|g;
  2803.       $math=~s|\\202|\)|g;
  2804.       &math2tex($math);
  2805.       open(SCRATCH,">$scr.tex");
  2806.       print SCRATCH $tex;
  2807.       close SCRATCH;
  2808.       `tex $scr.tex`;
  2809.       `dvips -E $scr.dvi`;
  2810.       open(LOG,"$scr.log");
  2811.       $log=<LOG>;
  2812.       close LOG;
  2813.       ($h,$d)=$log=~/[\w\W]*$prog: +([\d.]+)pt: +([\d.]+)/ ? ($1,$2) : (1,0);
  2814.       $above=$h+$d>0?sprintf("%.4f",$h/($h+$d)):0;
  2815.       open(PS,"$scr.ps");
  2816.       $pic=<PS>;
  2817.       if($pic=~/^%!/ && $pic=~/%%BoundingBox: +$V +$V +$V +$V/) {
  2818.         $xs=$3-$1;
  2819.         $ys=$4-$2;
  2820.         $llx=$1;
  2821.         $lly=$2;
  2822.         $ps="";
  2823.         for $i (split(/\n/,$pic)) {
  2824.           $ps.=$i."\n" if($i && $i!~/^%/);
  2825.         }
  2826.         if($ps=~/\nTeXDict begin/) {
  2827.           if(!$ph) {
  2828.             $ph="/DH {1 F div dup scale /showpage {} D\n$`$&} D\n%EndDH\n";
  2829.             $pv=$ph.$pv;
  2830.           }
  2831.           $ps="save -$llx -$lly translate\nDH$' restore";
  2832.         }
  2833.       }
  2834.       $nimg++;
  2835.       $nps--;
  2836.       push(@XS,$xs);
  2837.       push(@YS,$ys);
  2838.       push(@IX,$nps);
  2839.       push(@IT,2);
  2840.       $pv.="/P$nimg {$ps} D\n";
  2841.       $eps{"P$nimg"}=$ps;
  2842.       $_=$beg.")$above 3 (P$nimg) $nimg IM(".$end;
  2843.     } else {
  2844.       $math=~s/<math$R//i;
  2845.       $_=$beg.$math.$end;
  2846.     }
  2847.   chdir $cwd;
  2848.   s|<[sS][uU][bB]$R|)Sb(|g;
  2849.   s|<[sS][uU][pP]$R|)Sp(|g;
  2850.   s"</[sS][uU]([bB]|[pP])>")Es("g;
  2851.   s|<[A-Za-z/!?]\w*$R||g;
  2852.   &ent($_);
  2853.   y/\003/>/;
  2854.   s/\004([^\004]*)\004/")".&getl($1)." Sl($&"/eg;
  2855.   if($opt_H) {
  2856.     &dbg("Inserting potential hyphenation points\n") if($opt_d && $ndoc>0);
  2857.     $temp="";
  2858.     while(/\004([^\004]*)\004/) {
  2859.       $temp.=$`;
  2860.       $lang=$1;
  2861.       $end=$';
  2862.       if($end=~/\004([^\004]*)\004/) {
  2863.         $htext=$`;
  2864.         $end=$&.$';
  2865.       } else {
  2866.         $htext=$end;
  2867.         $end="";
  2868.       }
  2869.       $apa="";
  2870.       while($htext=~/(..?)\(([^)]*)/) {
  2871.         $slut=$';
  2872.         if($1 eq "XX") {
  2873.           $apa.=$`.$&;
  2874.           if($'=~/RP\(/) {
  2875.             $apa.=$`;
  2876.             $htext=$&.$';
  2877.           } else {
  2878.             $apa.=$slut;
  2879.             $htext="";
  2880.           }
  2881.         } elsif($1 eq ") ") {
  2882.           $apa.=$`.$&;
  2883.           $htext=$';
  2884.         } else {
  2885.           $apa.="$`$1(";
  2886.           $htext=$';
  2887.           ($txt=$2)=~s/[$ltrs]{$hyphenation{'min'},}/&hyph($&)/eg;
  2888.           $apa.=$txt;
  2889.         }
  2890.       }
  2891.       $_=$apa.$slut.$end;
  2892.     }
  2893.     $_=$temp.$_;
  2894.   s/\004([^\004]*)\004//g;
  2895.   $_[0]=$_;
  2896. sub ent {
  2897.   local($_)=@_;
  2898.   for $char (keys %ent) {s/&($char)(;|$|(?=\W))/chr($ent{$char})/eg};
  2899.   for $char (keys %symb) {s/&($char)(;|$|(?=\W))/)SY(\\$symb{$char})ES(/g};
  2900.   s|<?|<|g;
  2901.   s|>?|>|g;
  2902.   s|"?|"|g;
  2903.   s/&($space);?/)$space{$1} Se(/g;
  2904.   s|&#x($X+);?|"&#".hex($1).";"|eg;
  2905.   s|&#(\d+);?|$1==38?"\005":$1<256?chr($1):$&|eg;
  2906.   s/(\005|&?)/\&/g;
  2907.   $_[0]=$_;
  2908. sub spec {
  2909.   $_[0]=~s/(\\|\(;|$|(?=\W)))/\\200/g;
  2910.   $_[0]=~s/(\(|((;|$|(?=\W)))/\\201/g;
  2911.   $_[0]=~s/(\)|)(;|$|(?=\W)))/\\202/g;
  2912.   $_[0]=~s/&(there4|#8756)(;|$|(?=\W))/)SY(\\200)ES(/g;
  2913. sub math2tex {
  2914.   local($_)=@_;
  2915.   local($beg,$rest);
  2916.   %a=("line","overline",
  2917.   "cub","overbrace",
  2918.   "hat","widehat",
  2919.   "tilde","widetilde",
  2920.   "larr", "overleftarrow",
  2921.   "rarr", "overrightarrow");
  2922.   %b=("line","underline",
  2923.   "cub","underbrace",
  2924.   "hat","widehat",
  2925.   "tilde","widetilde");
  2926.   %s=("medium","\\big",
  2927.   "large","\\Big",
  2928.   "huge","\\bigg");
  2929.   ($mattr)=/<math$R/i;
  2930.   $st=$mattr=~/class\s*=\s*["']?chem/i?'\rm ':'';
  2931.   $di=$mattr=~/class\s*=\s*["']?displayed/i?'\displaystyle ':'';
  2932.   s/<math$R//gi;
  2933.   s/\\/\\backslash/g;
  2934.   s/__/_\\>_/gi;
  2935.   s/\^\^/^\\>^/gi;
  2936.   s/_([^_]+)_/_{$1}/g;
  2937.   s/\^([^^]+)\^/^{$1}/g;
  2938.   s/ ?/\\,/g;
  2939.   s/&sp;?/\\>/g;
  2940.   s/ ?/\\;/g;
  2941.   s/ ?/\\>/g;
  2942.   s/ε?/\\varepsilon /g;
  2943.   s/υ?/\\upsilon /g;
  2944.   s/ϖ?/\\varpi /g;
  2945.   s/ς?/\\varsigma /g;
  2946.   s/ϑ?/\\vartheta /g;
  2947.   s/ϕ?/\\varphi /g;
  2948.   s/ϒ?/\\Upsilon /g;
  2949.   s/ο?/o/g;
  2950.   s/±?/\\pm /g;
  2951.   s/∨?/\\vee /g;
  2952.   s/∧?/\\wedge /g;
  2953.   s/≈?/\\approx /g;
  2954.   s/⊆?/\\subseteq /g;
  2955.   s/⊂?/\\subset /g;
  2956.   s/⊇?/\\supseteq /g;
  2957.   s/⊃?/\\supset /g;
  2958.   s/∈?/\\in /g;
  2959.   s/←?/\\leftarrow /g;
  2960.   s/→?([_^])/\\mathop\\rightarrow\\limits$1 /g;
  2961.   s/→?/\\rightarrow /g;
  2962.   s/↑?/\\uparrow /g;
  2963.   s/↓?/\\downarrow /g;
  2964.   s/↔?/\\leftrightarrow /g;
  2965.   s/⇐?/\\Leftarrow /g;
  2966.   s/⇒?/\\Rightarrow /g;
  2967.   s/⇑?/\\Uparrow /g;
  2968.   s/⇓?/\\Downarrow /g;
  2969.   s/∃?/\\exists /g;
  2970.   s/&inf;?/\\infty /g;
  2971.   s/&?int;?/\\int\\limits /g;
  2972.   s/&?sum;?/\\sum\\limits /g;
  2973.   s/&?prod;?/\\prod\\limits /g;
  2974.   s/&pd;?/\\partial /g;
  2975.   s/{?/\\{/g;
  2976.   s/}?/\\}/g;
  2977.   s/<t>/\\hbox{/gi;
  2978.   s/<b>/\\bf /gi;
  2979.   s/<bt>/{\\bf\\hbox{/gi;
  2980.   s/<sub$R/_{/gi;
  2981.   s/<sup$R/\^{/gi;
  2982.   s/<box\s*size=["']?(\w+)["']?>/{\\def\\lft{$s{$1}}\\def\\rgt{$s{$1}}/gi;
  2983.   s/<box$R/{/gi;
  2984.   s/<text\s*>/\\hbox{/gi;
  2985.   s/([\(\[\|])\s*<left>/\\lft$1/gi;
  2986.   s/<right>/\\rgt /gi;
  2987.   s/<(atop|choose|over)>/\\\L$1 /gi;
  2988.   s/<of>/}\\of{/gi;
  2989.   s/<bar>/\\overline{/gi;
  2990.   s/<vec>/\\overrightarrow{/gi;
  2991.   s/<hat>/\\widehat{/gi;
  2992.   s/<tilde>/\\widetilde{/gi;
  2993.   s/<(sqrt|root|vec|dot|ddot|hat|tilde)>/\\\L$1\{/gi;
  2994.   while(/<above\s+sym\s*=\s*["']?equals["']?\s*>/i) {
  2995.     $beg=$`."\\overline{\\overline{";
  2996.     $rest=$';
  2997.     $rest=~s/<\/above>/}}/i;
  2998.     $_=$beg.$rest;
  2999.   s/<above\s*>/\\overline{/gi;
  3000.   s/<above\s+sym\s*=\s*["']?(\w+)["']?\s*>/\\$a{$1}\{/gi;
  3001.   s/<below\s*>/\\underline{/gi;
  3002.   s/<below\s+sym\s*=\s*["']?(\w+)["']?\s*>/\\$b{$1}\{/gi;
  3003.   s/<\/(math|row|item|b)>//gi;
  3004.   s/<\/(box|t|sup|sub|sqrt|root|vec|bar|dot|ddot|hat|tilde|above|below|text|array)>/}/gi;
  3005.   s/<\/bt>/}}/gi;
  3006.   s/<?/< /gi;
  3007.   s/>?/>/gi;
  3008.   s/&(\w+);?/\\$1 /gi;
  3009.   s/<array$R/\\matrix{/gi;
  3010.   s/<row>\s*<item$R//i;
  3011.   s/<row>\s*<item$R/\\cr /gi;
  3012.   s/<item>/&/gi;
  3013.   s/<[^ ]$R//gi;
  3014.   s/\n*$//;
  3015.   $tex="\\batchmode\\magnification=$mag\\hsize=40cm\\nopagenumbers\n"
  3016.  ."\\def\\lft{\\left}\\def\\rgt{\\right}\n\\setbox0=\\hbox{\$$st$di".$_."\$}\n"
  3017.  ."\\immediate\\write0{$prog: \\the\\ht0: \\the\\dp0}\\box0\n\\end\n";
  3018. sub Getopts {
  3019.   local($optlist)=@_;
  3020.   local(@args,$_,$opt,$opts,$rest,$olist,$plist,$found,@popts);
  3021.   local($errs)=0;
  3022.   local($[)=0;
  3023.   @args=split( /\|/, $optlist );
  3024.   for $opt (@args) {
  3025.     if(substr($opt,-1,1) ne ':') {$olist.=$opt}
  3026.     else {$plist.=$opt}
  3027.   @popts=split(/:/,$plist);
  3028.   while(@ARGV && ($_=$ARGV[0]) =~ /^-(.*)/) {
  3029.     $opt=$1;
  3030.     if($opt=~/^-/ && $optalias{"\L$'"}) {$opt=$optalias{"\L$'"}};
  3031.     if($opt =~ /^[$olist]+$/) {
  3032.       while ($char=chop $opt) {eval "\$opt_$char=1"}
  3033.       shift(@ARGV);
  3034.     }
  3035.     else {
  3036.       $found=0;
  3037.       for $opts (@popts) {
  3038.         $rest=substr($opt,length($opts));
  3039.         if(index($opt,$opts)==0) {
  3040.           $found=1;
  3041.           shift(@ARGV);
  3042.           if(length($rest)==0) {
  3043.             ++$errs unless @ARGV;
  3044.             $rest=shift(@ARGV);
  3045.           }
  3046.           eval "\$opt_$opts=\$rest";
  3047.         }
  3048.       }
  3049.       if(!$found) {
  3050.         &dbg("Unknown option: $opt\n");
  3051.         ++$errs;
  3052.         shift(@ARGV);
  3053.       }
  3054.     }
  3055.   $errs==0;
  3056. sub openps {
  3057.   open(STDOUT,">$opt_o") || die "*** Error opening $opt_o for output\n";
  3058. sub getalt {
  3059.   if($imgcmd eq "img") {
  3060.     $alt="";
  3061.     $match=0;
  3062.     if($img=~/alt\s*=\s*"([^"]*)"/i) {$alt=$1; $match=1};
  3063.     if(!$match && $img=~/alt\s*=\s*([\w\.-]+)/i) {$alt=$1; $match=1};
  3064.     if(!$match) {$alt=")WB IA WB("};
  3065.     $text="$alt )WB(";
  3066.     return;
  3067.   if($imgcmd eq "hr") {
  3068.     $text=$img=~/align\s*=\s*["']?(left|center|right)/i?")$algn{$1} ":")2 ";
  3069.     $text.=$img=~/size\s*=\s*["']?$V/i?$1:.6;
  3070.     $wd=1;
  3071.     if($img=~/width\s*=\s*["']?$V(%?)/i) {$wd=$2?$1/100:-$1};
  3072.     $text.=" $wd HR(";
  3073.     return;
  3074.   if($imgcmd eq "fig") {
  3075.     $text=")BN(";
  3076. sub xbmtops {
  3077.   $fc=1;
  3078.   $dp=1;
  3079.   ($xs,$ys)=$pic=~/^#define.* (\d+)[\w\W]*^#define.* (\d+)/;
  3080.   $nd=2*int(($xs+7)/8)*$ys;
  3081.   ($pic)=$pic=~/[^#].* char.*[\w\W]*{([\w\W]*)}/;
  3082.   $pic=~s/[ ,\n\r]*0x[ ,]*//g;
  3083.   $pic=~y/01246789bdef/f7bd91e62480/;
  3084.   $bm=unpack("H*", pack("h*",$pic));
  3085. sub pmtops {
  3086.   $pm=~/^P([4-6])/;
  3087.   $maptype=$1;
  3088.   return if(!$maptype);
  3089.   $pm=$';
  3090.   $bm="";
  3091.   $nint=3;
  3092.   $dp=8;
  3093.   if($maptype==4) {
  3094.     $nint=2;
  3095.     $dp=1;
  3096.   undef @num;
  3097.   $found=0;
  3098.   while($pm && $found<$nint) {
  3099.     if($pm=~/^\s*(\d+)/) {$num[$found]=$1};
  3100.     if($num[$found]) {
  3101.       $found++;
  3102.       $pm=$';
  3103.     } elsif($pm=~/^\s*#.*\n/) {
  3104.       $pm=$';
  3105.     } else {
  3106.       return;
  3107.     }
  3108.   ($b)=$pm=~/\s([\w\W]*)/;
  3109.   ($xs,$ys,$bits)=@num;
  3110.   return if($bits>255);
  3111.   $fc=1;
  3112.   if($maptype==6) {
  3113.     $fc=3;
  3114.     $nd=6*$xs*$ys;
  3115.     $bm=unpack("H*",$b);
  3116.   } else {
  3117.     $bm=unpack("H*",$b);
  3118.     if($maptype==4) {
  3119.       $nd=2*int(($xs+7)/8)*$ys;
  3120.       $bm=~y/0123456789abcdef/fedcba9876543210/;
  3121.     } else {
  3122.       $nd=2*$xs*$ys;
  3123.     }
  3124. sub trans {
  3125.   $next = 13;
  3126.   $temp = ord substr($pic,10,1);
  3127.   if($temp & 0x80) {$next += 3*2**(($temp & 0x07) + 1)} else {return};
  3128.   $byte = ord substr($pic,$next,1);
  3129.   while($byte != 0x3b && $next <= length $pic) {
  3130.     if($byte == 0x21) {
  3131.       if(ord substr($pic,$next+1,1) == 0xf9) {
  3132.         if(ord substr($pic,$next+3,1) & 0x01) {
  3133.           &dbg("Transparent\n") if($opt_d);
  3134.           $src{$URL}=$pic;
  3135.           $idx = 3*(ord substr($pic,$next+6,1))+13;
  3136.           substr($pic,$idx,3) = pack("H*",$red.$grn.$blu) if($idx<length $pic);
  3137.         }
  3138.         return;
  3139.         $next += 2;
  3140.         &skip;
  3141.       } else {
  3142.         $next += 2;
  3143.         &skip;
  3144.       }
  3145.     } elsif($byte == 0x2c) {
  3146.       $next += 10;
  3147.       $temp = ord substr($pic,$next-1,1);
  3148.       if($temp & 0x80) {$next += 3*2**(($temp & 0x07) + 1)};
  3149.       $next++;
  3150.       &skip;
  3151.     } else {return}
  3152. sub skip {
  3153.   $byte = ord substr($pic,$next,1);
  3154.   while($byte != 0) {
  3155.     $next += $byte + 1;
  3156.     $byte = ord substr($pic,$next,1);
  3157.   $next++;
  3158.   $byte = ord substr($pic,$next,1);
  3159. sub run {
  3160.   &dbg("@_\n") if($opt_d);
  3161.   $pm=`@_`;
  3162. sub geturl {
  3163.   local($url)=@_;
  3164.   &dbg("Retrieving $url");
  3165.   if($package{'libwww-perl'} || $package{'jfriedl'}) {
  3166.     warn "\n";
  3167.     &gu();
  3168.     if($code==401) {
  3169.       &prompt("\nDocument requires username and password\n\nUsername: ",$user);
  3170.       &prompt("Password: ",$pass);
  3171.       &gu($user,$pass);
  3172.     }
  3173.     $_[1]=$cont;
  3174.   } elsif(defined $geturl) {
  3175.     &dbg("...");
  3176.     $_[1]=`$geturl '$url'`;
  3177.     if($?) {
  3178.       &dbg("\n*** Error opening $url\n");
  3179.       return 0;
  3180.     }
  3181.     &dbg("done\n");
  3182.     if($_[1]=~/\r?\n\r?\n/) {
  3183.       $_[1]=$';
  3184.       $dhead=$`;
  3185.       ($code)=$dhead=~/HTTP\/\S+ +(\d+)/i;
  3186.       ($contyp)=$dhead=~/Content-type:\s+(.*)/i;
  3187.     } else {
  3188.       $code=500;
  3189.     }
  3190.   $_[0]=$url;
  3191.   $code<300;
  3192. sub gu {
  3193.   if($package{'libwww-perl'}) {
  3194.     require LWP::UserAgent;
  3195.     $ua=new LWP::UserAgent;
  3196.     $req = HTTP::Request->new(GET => $url);
  3197.     $req->authorization_basic(@_) if(@_);
  3198.     $ua->agent($spoof) if($spoof);
  3199.     my $res = $ua->request($req);
  3200.     $code=$res->code;
  3201.     $contyp=$res->header('content-type');
  3202.     $cont=$res->content;
  3203.   } else {
  3204.     require "www.pl";
  3205.     @opts=@_?("authorization=$_[0]:$_[1]"):();
  3206.     push(@opts,"quiet") if(!$opt_d);
  3207.     $www::useragent=$spoof if($spoof);
  3208.     ($status,$memo,%info)=&www::open_http_url(*FILE,$url,@opts);
  3209.     $code=$info{'CODE'};
  3210.     ($contyp)=$info{'HEADER'}=~/Content-type:\s+(.*)/i;
  3211.     $cont=<FILE>;
  3212. sub pictops {
  3213.   if($opt_g) {
  3214.     $fc=1;
  3215.     $pg1="pgm";
  3216.     $pg2="|ppmtopgm";
  3217.   } else {
  3218.     $fc=3;
  3219.     $pg1="ppm";
  3220.     $pg2="";
  3221.   ($type)=$URL=~/([^\?]+)\??/;
  3222.   ($type)=$type=~/\.(\w+)$/;
  3223.   $bm="";
  3224.   $ps="";
  3225.   $pm="";
  3226.   if($opt_U && $src{$URL} && !$cmd{$URL.$red.$grn.$blu}) {
  3227.     $pic=$src{$URL};
  3228.   } elsif($URL=~m|://|) {
  3229.     &geturl($URL,$pic) || return;
  3230.   } else {
  3231.     $flag=0;
  3232.     if($opt_O) {
  3233.       $orig=$URL;
  3234.       unless($orig=~s/\.\w*$/.ps/) {$orig.=".ps"};
  3235.       if(open(ORIG,"$orig")) {
  3236.         $pic=<ORIG>;
  3237.         close ORIG;
  3238.         if($pic=~/^%!/ && $pic=~/%%BoundingBox:/) {
  3239.           $flag=1;
  3240.           &dbg("Using $orig as original for $URL\n") if($opt_d);
  3241.         }
  3242.       }
  3243.     }
  3244.     if(!$flag) {
  3245.       if(open(PIC,"$URL")) {
  3246.         binmode PIC;
  3247.         $pic=<PIC>;
  3248.         close PIC;
  3249.       } else {
  3250.         &dbg("*** Error opening $URL\n");
  3251.         return;
  3252.       }
  3253.     }
  3254.   $pic=~s/^[\n\r]*//;
  3255.   &trans if($pic=~/^GIF/);
  3256.   open(SCRATCH,">$scr");
  3257.   print SCRATCH "$pic";
  3258.   close SCRATCH;
  3259.   if($pic=~/^%!/ && $pic=~/%%BoundingBox: +$V +$V +$V +$V/) {
  3260.     $xs=$3-$1;
  3261.     $ys=$4-$2;
  3262.     $ps="save\n0 0 M\nIS IS scale\n/showpage {}D\n-$1 -$2 translate\n";
  3263.     for $i (split(/\n/,$pic)) {
  3264.       $ps.=$i."\n" if($i && $i!~/^%/);
  3265.     }
  3266.     $ps.="restore";
  3267.   } elsif($type=~/.xbm$/i || $pic=~/^#define/) {
  3268.     &xbmtops;
  3269.   } elsif($package{'ImageMagick'}) {
  3270.     if($package{'PerlMagick'}) {
  3271.       $imobj=Image::Magick->new;
  3272.       $mess=$imobj->Read($scr);
  3273.       if($mess) {
  3274.         &dbg("$mess\n");
  3275.       } else {
  3276.         $mess=$imobj->Write("$scr\.$pg1");
  3277.         &dbg("$mess\n") if($mess);
  3278.       }
  3279.       undef $imobj;
  3280.     } else {
  3281. #      &run("convert $scr $pg1:-");
  3282.       &run("convert $scr $scr\.$pg1");
  3283.     }
  3284.     open(PNM,"$scr\.$pg1");
  3285.     binmode PNM;
  3286.     $pm=<PNM>;
  3287.     close PNM;
  3288.     if(!$pm && $pic=~/^\377\330/ && $package{'djpeg'}) {
  3289.       &run("djpeg $scr$pg2");
  3290.     }
  3291.   } elsif($pic=~/^\377\330/ && $package{'djpeg'}) {
  3292.     &run("djpeg $scr$pg2");
  3293.   } elsif($package{'pbmplus'} || $package{'netpbm'}) {
  3294.     if($pic=~/^GIF/) {
  3295.       &run("$giftopm $scr");
  3296.     } else {
  3297.       &run("anytopnm $scr");
  3298.     }
  3299.     if($opt_g && $pm=~/^P6/) {
  3300.       open(SCRATCH,">$scr");
  3301.       print SCRATCH $pm;
  3302.       close SCRATCH;
  3303.       &run("ppmtopgm $scr");
  3304.     }
  3305.   &pmtops if(!$bm);
  3306.   return if(!$bm);
  3307.   $bm=substr($bm,0,$nd);
  3308.   $pad=$nd-length($bm);
  3309.   if($pad) {$bm.="f" x $pad};
  3310.   $bm=~s/(.{60})/$1\n/g;
  3311. sub math2sym {
  3312.   local($_)=@_;
  3313.   s/<math$R//gi;
  3314.   for $char (keys %symb) {s/&($char)(;|$|(?=\W))/\\$symb{$char}/g};
  3315.   $stat=!/([&<][a-zA-Z]|[_^{])/;
  3316.   s/[a-zA-Z\s]*[a-zA-Z][a-zA-Z\s]*/)ES()I($&)ES()SY(/g;
  3317.   s/(\\200|\\201|\\202)/)RO($&)ES(/g;
  3318.   $sym=")SY($_)ES(";
  3319.   $stat;
  3320. sub varsub {
  3321.   for (@_) {
  3322.     if(s/(^|[^\\])\$(T|N|U|H|A)/$1)join $vars{$2} join(/g) {$_="()$_\join"};
  3323.     s/(^|[^\\])\$D\{($S)\}/"$1".POSIX::strftime($+,@now)/eg;
  3324.     s/(^|[^\\])\$D/"$1".POSIX::strftime($datefmt,@now)/eg;
  3325.     s/(^|[^\\])\\/$1/g;
  3326.     s/\(\)join//g;
  3327.     s/\(\) ?(\([^)]*\)|\w+) ?join/$1/g;
  3328. sub follow {
  3329.   return 0 if(!$opt_W);
  3330.   $H=$lnk=~/\.html?(#|$)/i || $lnk=~m|.+//.+/[^/\.]*$|;
  3331.   $T=$rev && ($revtoc && $ndoc==1 || $ndoc>1 && $H);
  3332.   $L=$b1=~m|://| && $lnk=~m"^$b1(/|$)" || $b1!~m|://| && $lnk!~m|://|;
  3333.   $B=$B2 && $lnk=~/^$B2/ || !$B2 && $lnk!~m"(^\.\.|://)";
  3334.   return $rlnk && ($H || $T) if($rel);
  3335.   return $L && ($H || $T) if($local);
  3336.   return $B && ($H || $T) if($below);
  3337.   return $H || $T if($rev);
  3338.   $H;
  3339. sub DSC {
  3340.   &dbg("Generating DSC PostScript\n") if($opt_d);
  3341.   %op=("moveto",2, "rmoveto",2, "lineto",2, "rlineto",2, "translate",2,
  3342.        "scale",2, "show",1, "awidthshow",6, "stroke",0, "save",0, "restore",0,
  3343.        "gsave",0, "grestore",0, "showpage",0, "newpath",0, "setlinewidth",1,
  3344.        "setlinejoin",1, "setgray",1, "closepath",0, "fill",0, "arc",5,
  3345.        "setrgbcolor",3, "rotate",1, "image",5, "colorimage",7);
  3346.   %sho=("moveto","M", "rmoveto","RM", "lineto","L", "rlineto","RL", "show","S",
  3347.         "showpage","N", "awidthshow","A");
  3348.   $i=0;
  3349.   $po="/OU true D\n";
  3350.   for (keys %op) {
  3351.     $cmd=$sho{$_}?$sho{$_}:$_;
  3352.     push(@val,$cmd);
  3353.     $in{$_}=$i++;
  3354.     $j=$op{$_}+1;
  3355.     $extra="";
  3356.     if(/showpage/) {$extra="Bb{Xl Yl Xh Yh}if Pn "};
  3357.     if(/image/) {$extra="K ";$j++};
  3358.     $t=$op{$_}?"$op{$_} copy $extra$in{$_} $j array astore":"[$extra$in{$_}]";
  3359.     $po.="/$_ {OU {$t ==} if $_}d\n";
  3360.   $po.="/pdfmark {$i] ==} D\n";
  3361.   $in{"pdfmark"}=$i++;
  3362.   push(@val,"pdfmark");
  3363.   $po.="/NF {OU{2 copy E $i 3 array astore ==}if ONF}d\n"
  3364.       ."/EX {[IS EC] ==} D\n/Cd {} D\n/DU {TU PM 1 eq and TP and{Pn ==}if}d\n"
  3365.       ."/BB {US Bb{dup Yl lt{dup /Yl E D}if dup Yh gt{/Yh E D}{pop}ie\n"
  3366.       ." dup Xl lt{dup /Xl E D}if dup Xh gt{/Xh E D}{pop}ie}\n"
  3367.       ." {/Yl E D /Yh Yl D /Xl E D /Xh Xl D /Bb t D}ie}D\n";
  3368.   $in{"Nf"}=$i++;
  3369.   s|/(NF.*)|/O$1|;
  3370.   s|/BB.*|$po|;
  3371.   push(@val,"Nf");
  3372.   if($psin) {
  3373.     ($ti)=/%%Title: (.*)/;
  3374.     if(m|/BM (\d+)|) {
  3375.       $nbit=$1;
  3376.       for $vec ("IT","WS") {
  3377.         /\/$vec \[(.*)\]/;
  3378.         @$vec=split(' ',$1);
  3379.       }
  3380.       /\nSB/;
  3381.       for (0..$nbit-1) {
  3382.         $'=~/\n\n/;
  3383.         push(@BM,$`);
  3384.       }
  3385.     }
  3386.     ($epsf)=/(\n\/P\d+_?\d* [\w\W]*)%Endpv/;
  3387.     while($epsf=~/\n\/(P\d+_?\d*) \{/g) {
  3388.       $pid=$1;
  3389.       $rest=$';
  3390.       $temp=$'=~/\/P\d+_?\d* \{/?$`:$rest;
  3391.       ($eps{$pid})=$temp=~/([\w\W]*)} D/;
  3392.     }
  3393.     if(/\/DH {/) {
  3394.       $'=~/%EndDH/;
  3395.       $ph="/DH {$`";
  3396.     }
  3397.   $j=-1;
  3398.   for $i (0..$#IT) {
  3399.     $j++ if($IT[$i] == 0);
  3400.     push(@ix,$j);
  3401.   $dfn="/F $opt_s D\n$ph";
  3402.   for (keys %sho) {
  3403.     $dfn.="/$sho{$_} {$_} d\n";
  3404.   open(SCR,">$scr.ps");
  3405.   print SCR "$_ quit\n";
  3406.   close SCR;
  3407.   $cd{')]'}="Cd ";
  3408.   $io="($in{'image'}|$in{'colorimage'})";
  3409.   $_="";
  3410.   $temp="";
  3411.   $pn="";
  3412.   $start=1;
  3413.   $EPS="%%EndPageSetup";
  3414.   $pp=0;
  3415.   $n=0;
  3416.   for $line (split(/\r?\n/,`gs -q -dNODISPLAY $scr.ps</dev/null`)) {
  3417.     if(!$pp) {
  3418.       $mv="";
  3419.       $cx="";
  3420.       $cy="";
  3421.     }
  3422.     if($start && $line!~/ $in{"pdfmark"}\]$/) {
  3423.       $pdf=$temp;
  3424.       $temp="";
  3425.       $start=0;
  3426.     }
  3427.     $pp=$line=~/^\[(\S+) (\S+) ($in{'moveto'}|$in{'rmoveto'}|$in{'Nf'})\]$/;
  3428.     S:{
  3429.       if($3==$in{"Nf"}) {
  3430.         $fn="$1 $2 $val[$3]\n";
  3431.         last S;
  3432.       }
  3433.       if($3==$in{"moveto"}) {
  3434.         $cx=$1;
  3435.         $cy=$2;
  3436.         $mv=sprintf("%.1f %.1f %s\n",$1,$2,$val[$3]);
  3437.         last S;
  3438.       }
  3439.       if($3==$in{"rmoveto"}) {
  3440.         if($mv) {
  3441.           $cx+=$1;
  3442.           $cy+=$2;
  3443.           $mv=sprintf("%.1f %.1f %s\n",$cx,$cy,$val[$in{"moveto"}]);
  3444.         } else {
  3445.           $temp.=sprintf("%.1f %.1f %s\n",$1,$2,$val[$3]) if($1||$2);
  3446.         }
  3447.         last S;
  3448.       }
  3449.       if($line=~s/^\[(.*)\((\S*)\) ($in{"showpage"})\]$/pgsave restore $val[$3]/) {
  3450.         $pbb="";
  3451.         if($1) {
  3452.           ($llx,$lly,$urx,$ury)=split(/ /,$1);
  3453.           $llx=int($llx);
  3454.           $lly=int($lly);
  3455.           $urx=int($urx+1);
  3456.           $ury=int($ury+1);
  3457.           $pbb="%%PageBoundingBox: $llx $lly $urx $ury\n";
  3458.           if(!defined($Llx) || $llx<$Llx) {$Llx=$llx};
  3459.           if(!defined($Lly) || $lly<$Lly) {$Lly=$lly};
  3460.           if(!defined($Urx) || $urx>$Urx) {$Urx=$urx};
  3461.           if(!defined($Ury) || $ury>$Ury) {$Ury=$ury};
  3462.         }
  3463.         $pn.="," if($pn && $2);
  3464.         $n++;
  3465.         @df=();
  3466.         for(0..$#docfonts) {
  3467.           push(@df,$docfonts[$_]) if($uf{$_}==$n);
  3468.         }
  3469.         push(@df,"Symbol") if($uf{"-1"}==$n);
  3470.         $fu="";
  3471.         $tmp=@df?"%%PageResources: font":"";
  3472.         &splitline(@df);
  3473.         $_.="%%Page: $pn$2 $n\n$fu$pbb%%BeginPageSetup\n/pgsave save D\n$temp$line\n";
  3474.         $EPS="%%EndPageSetup";
  3475.         $temp="";
  3476.         $line="";
  3477.         $fn="";
  3478.         $mv="";
  3479.         $pn="";
  3480.         last S;
  3481.       }
  3482.       if($line=~/^\[([^(]*)(\(.*\)) ($in{"show"}|$in{"awidthshow"})\]$/) {
  3483.         if(length $2>2) {
  3484.           $line="$fn$1$2 $val[$3]";
  3485.           if($fn=~/(\S+) Nf/ && $uf{$1}!=$n+1) {
  3486.             $uf{$1}=$n+1;
  3487.             $fnt=$1<0?"Symbol":$docfonts[$1];
  3488.             $line="%%IncludeResource: font $fnt\n$line";
  3489.           }
  3490.           $fn="";
  3491.           $pp=0;
  3492.         } else {
  3493.           $pp=1;
  3494.         }
  3495.         last S;
  3496.       }
  3497.       if($line=~/^\[(\S+) (\S+) ($in{"scale"})\]$/) {
  3498.         $line=$1!=1||$2!=1?"$1 $2 $val[$3]\n$EPS":"$EPS";
  3499.         $EPS="";
  3500.         last S;
  3501.       }
  3502.       if($line=~/^\[(.*) (\d+) $io\]$/) {
  3503.         $li=$BM[$2]=~y/\n/\n/+2;
  3504.         $line="\/picstr $WS[$ix[$2]] string D\n$1\n"
  3505.              ."%%BeginData: $li Hex Lines\n$val[$3]\n$BM[$2]\n%%EndData";
  3506.         last S;
  3507.       }
  3508.       if($line=~/^\((.*)\)$/) {
  3509.         $pn=$1;
  3510.         $line="";
  3511.         last S;
  3512.       }
  3513.       last S if($line=~s/^\[([^\/].* )?(\d+)\]$/$1$val[$2]/);
  3514.       last S if($line=~s/(\)\])? (\/\w+) $in{"pdfmark"}\]$/$1 $cd{$1}$2 pdfmark/);
  3515.       last S if($line=~s/^\[(\S+) \((P\d+.*)\)\]$/\/IS $1 D\n$eps{$2}/);
  3516.       &dbg("$line\n");
  3517.     }
  3518.     if(!$pp && $mv.$line) {
  3519.       $mv=~s/\.0//g;
  3520.       $temp.="$mv$line\n";
  3521.     }
  3522.   @nf=();
  3523.   @sf=();
  3524.   $fontdef="";
  3525.   for(0..$#docfonts) {
  3526.     $ff=$ff{$docfonts[$_]};
  3527.     if($ff && $uf{$_}>0) {
  3528.       push(@sf,$docfonts[$_]);
  3529.       $fontdef.="%%BeginResource: font $docfonts[$_]\n$cont{$ff}\n%%EndResource\n";
  3530.       $cont{$ff}="";
  3531.     }
  3532.     push(@nf,$docfonts[$_]) if(!$ff && $uf{$_}>0);
  3533.   push(@nf,"Symbol") if($uf{"-1"}>0);
  3534.   $ti="@ARGV" unless($psin);
  3535.   $or=$opt_L?"Landscape":"Portrait";
  3536.   $setup="%%BeginSetup\n";
  3537.   $setup.="$dupl\n" if($dupl);
  3538.   $setup.="$fontdef" if($fontdef);
  3539.   $fu="";
  3540.   $tmp=@nf?"%%DocumentNeededResources: font":"";
  3541.   &splitline(@nf);
  3542.   $tmp=@sf?"%%DocumentSuppliedResources: font":"";
  3543.   &splitline(@sf);
  3544.   s/\\(200|201|202)/\\$ssy{$1}/g;
  3545.   $dd="Clean7Bit";
  3546.   $dd="Clean8Bit" if(($fontdef.$_)=~/[\200-\377]/);
  3547.   $dd="Binary" if(($fontdef.$_)=~/[\000-\010\013-\014\016-\036]/);
  3548.   $time=localtime;
  3549.   print <<EOT;
  3550. %!PS-Adobe-3.0
  3551. %%Title: $title
  3552. %%Creator: $version
  3553. %%CreationDate: $time
  3554. $fu%%DocumentData: $dd
  3555. %%Orientation: $or
  3556. %%BoundingBox: $Llx $Lly $Urx $Ury
  3557. %%Pages: $n
  3558. %%EndComments
  3559. %%BeginProlog
  3560. /d {bind def} bind def
  3561. /D {def} d
  3562. /ie {ifelse} d
  3563. /E {exch} d
  3564. /t true D
  3565. /f false D
  3566. $defs/Nf {dup 0 ge{FL E get}{pop /Symbol}ie findfont E scalefont setfont} D
  3567. /IP {currentfile picstr readhexstring pop} D
  3568. /WF $wf D
  3569. $dfn%%EndProlog
  3570. $setup$reenc$pdf%%EndSetup
  3571. $_%%EOF
  3572. sub splitline {
  3573.   for (@_) {
  3574.     if(length($tmp.$_)>78) {
  3575.       $fu.="$tmp\n";
  3576.       $tmp="%%+ font";
  3577.     }
  3578.     $tmp.=" $_";
  3579.   $fu.="$tmp\n" if($tmp);
  3580. sub ref {
  3581.   @pnum=();
  3582.   /.*\s*$/;
  3583.   open(SCR,">$scr.ps");
  3584.   print SCR "$`HN{==}forall $& quit\n";
  3585.   close SCR;
  3586.   $pnum=`gs -q -dNODISPLAY $scr.ps</dev/null`;
  3587.   while($pnum=~/\([^)]*\)/g) {push(@pnum,$&)};
  3588.   $pnum="@pnum";
  3589.   &cut($pnum);
  3590.   s|/HN [^D]*D|/HN [$pnum] D|;
  3591. sub cut {
  3592.   $_[0]=~s/(.{70}[^ \n]*) ([^ ])/$1\n$2/g;
  3593. sub fin {
  3594.   if($opt_D) {
  3595.     &DSC;
  3596.   } else {
  3597.     print;
  3598.   if($opt_d) {
  3599.     print DBG "\n";
  3600.     close DBG;
  3601.   unlink "$scr","$scr.ps","$scr.ppm","$scr.tex","$scr.dvi","$scr.log" if($scr);
  3602.   exit;
  3603. sub col2rgb {
  3604.   $rgb=$colour{"\L$_[0]"}?($colour{"\L$_[0]"}):$_[0];
  3605.   @cvec=$rgb=~/($X$X)($X$X)($X$X)/?($1,$2,$3):();
  3606.   @cvec?"[16#$1 16#$2 16#$3]":"";
  3607. sub inihyph {
  3608.   if($hyphenation_file{$lang}) {
  3609.     $hyfile=$hyphenation_file{$lang};
  3610.   } else {
  3611.     &dbg("No hyphenation file for language '$lang'\n");
  3612.     $lng=$lang;
  3613.     while($lng=~s/-?[^-]+$// && !$hyphenation_file{$lng}) {};
  3614.     $hyfile=$hyphenation_file{$lng};
  3615.     &dbg(" ..using $hyfile\n");
  3616.   if($init{$hyfile}) {
  3617.     $rep{$lang}=$refl{$hyfile};
  3618.     return;
  3619.   if(open(HYPH,$hyfile)) {
  3620.     &dbg("Reading hyphenation patterns from $hyfile\n") if($opt_d);
  3621.     <HYPH>=~/\\patterns{.*/;
  3622.     close HYPH;
  3623.     $def=$`;
  3624.     ($patterns=$')=~s/\^\^($X$X)/chr hex $1/eg;
  3625.     $upp{$lang}='';
  3626.     $low{$lang}='';
  3627.     while ($def=~/\\lccode(`\\?\^\^|")($X$X)=(`\\?\^\^|")($X$X)/g) {
  3628.       if($2 ne $4) {
  3629.         $uc=$2;
  3630.         $lc=$4;
  3631.         if($`=~/\n$/ || $`!~/%.*$/) {
  3632.           $upp{$lang}.=chr hex $uc;
  3633.           $low{$lang}.=chr hex $lc;
  3634.         }
  3635.       }
  3636.     }
  3637.     while ($def=~/\\let\\(\w+)=(\^\^|")($X$X)/g) {
  3638.       $key=$1;
  3639.       $value=chr hex $3;
  3640.       $tex{$key}=$value if($`=~/\n$/ || $`!~/%.*$/);
  3641.     }
  3642.     for $key (keys %tex) {
  3643.       $patterns=~s/\\$key */$tex{$key}/g;
  3644.     }
  3645.     if($lang=~/^de/) {
  3646.       %de=('"a',228, '"o',246, '"u',252, '\3', 223);
  3647.       $patterns=~s/\\c\{[^}]*\}//g;
  3648.       $patterns=~s/\\n\{([^}]*)\}/$1/g;
  3649.       $patterns=~s/("a|"o|"u|\\3)/chr $de{$1}/eg;
  3650.       $upp{"de"}=~s/\337//;
  3651.       $low{"de"}=~s/\377//;
  3652.     }
  3653.     if($lang=~/^is/ && !$upp{"is"}) {
  3654.       %is=("'a","\341", "'e","\351", "'i","\355", "'o","\363", "'u","\372",
  3655.            "'y","\375", '"x',"\346", '"o',"\366", "'d","\360", "`t","\376");
  3656.       $isch=join("|",keys %is);
  3657.       $patterns=~s/($isch)/$is{$1}/g;
  3658.       $upp{"is"}="\301\311\315\323\332\335\306\326\336\320";
  3659.       $low{"is"}="\341\351\355\363\372\375\346\366\376\360";
  3660.     }
  3661.     if($lang=~/^fi/ && !$upp{"fi"}) {
  3662.       $upp{"fi"}="\304\326";
  3663.       $low{"fi"}="\344\366";
  3664.     }
  3665.     if($lang=~/^fr/ && !$upp{"fr"}) {
  3666.       $upp{"fr"}="\300\302\307\311\310\312\313\316\317\324\326\333\226";
  3667.       $low{"fr"}="\340\342\347\351\350\352\353\356\357\364\366\373\225";
  3668.     }
  3669.     if($lang=~/^es/ && !$upp{"es"}) {
  3670.       $upp{"es"}="\301\311\315\323\321\332\334";
  3671.       $low{"es"}="\341\351\355\363\361\372\374";
  3672.     }
  3673.     $patterns=~s/\{([\w\W]*?)\}/[$1]/g;
  3674.     $patterns=~/}/;
  3675.     $end=$`;
  3676.     if($def.$'=~/\\hyphenation\[.*/) {
  3677.       $'=~/]/;
  3678.       $hyext=$`;
  3679.     }
  3680.     ($patterns=$end)=~s/%.*//g;
  3681.     for $key (split('\s+',$patterns)) {
  3682.       $value=$key;
  3683.       $key=~s/\d//g;
  3684.       $value=~s/^([$ltrs.])/0$1/;
  3685.       $value=~s/[$ltrs](\d)/$1/g;
  3686.       $value=~s/[$ltrs.]/0/g;
  3687.       $patt{"$key,$lang"}=$value if($value=~/^\d+$/);
  3688.     }
  3689.   } else {
  3690.     &dbg("Cannot open hyphenation file: $hyfile\n");
  3691.   $hext=$hyphenation_extfile{$lang};
  3692.   for(split('\s*:\s*',$hext)) {
  3693.     if(open(HEXT,$_)) {
  3694.       &dbg("Reading hyphenation extensions from $_\n") if($opt_d);
  3695.       $hyext.=<HEXT>;
  3696.       close HEXT;
  3697.     } else {
  3698.       &dbg("Cannot open hyphenation extension file: $_\n");
  3699.     }
  3700.   if($hyext) {
  3701.     for $key (keys %tex) {
  3702.       $hyext=~s/$key */$tex{$key}/g;
  3703.     }
  3704.     for $key (split('\s+',$hyext)) {
  3705.       $key=~s/\s+//g;
  3706.       $value="00$key\0";
  3707.       $key=~s/-//g;
  3708.       $value=~s/[$ltrs]/0/g;
  3709.       $value=~s/0-/1/g;
  3710.       $hext{"$key,$lang"}=$value;
  3711.     }
  3712.   $refl{$hyfile}=$lang;
  3713.   $rep{$lang}=$lang;
  3714.   $init{$hyfile}=1;
  3715. sub hyph {
  3716.   $word="\L$_[0]";
  3717.   eval "\$word=~y/$upp{$rep{$lang}}/$low{$rep{$lang}}/" if($upp{$rep{$lang}});
  3718.   $len=length($word);
  3719.   $h=$hext{"$word,$rep{$lang}"};
  3720.   if($h) {
  3721.     @br=split(//,$h);
  3722.   } else {
  3723.     @br=(0) x ($len+3);
  3724.     for $i (0..$len) {
  3725.       for $j (0..$len-$i) {
  3726.         $str=substr(".$word.",$j,$i+2);
  3727.         $pstr=$patt{"$str,$rep{$lang}"};
  3728.         if($pstr) {
  3729.           @patt=split(//,$pstr);
  3730.           for $k (0..$#patt) {
  3731.             $br[$k+$j]=$patt[$k] if($br[$k+$j]<$patt[$k]);
  3732.           }
  3733.         }
  3734.       }
  3735.     }
  3736.   $hword="";
  3737.   for $i (0..$len-1) {
  3738.     $hword.=substr($_[0],$i,1);
  3739.     if(($h || $i>$hyphenation{'start'}-2 && $i<$len-$hyphenation{'end'})
  3740.       && $br[$i+2]%2==1) {$hword.=")HY("};
  3741.   $hword.=")YH(" if(length $word < length $hword);
  3742.   $hword;
  3743. sub setel {
  3744.   $el=$_[0];
  3745.   eval "\%arr=\%$el";
  3746.   &fs($el);
  3747.   push(@font,$fontid{"\L$font"});
  3748.   push(@styl,$styl);
  3749.   push(@size,$arr{'font-size'});
  3750.   push(@alig,$algn{$arr{'text-align'}}-1);
  3751.   push(@topm,$arr{'margin-top'});
  3752.   push(@botm,$arr{'margin-bottom'});
  3753.   push(@lftm,$arr{'margin-left'});
  3754.   push(@rgtm,$arr{'margin-right'});
  3755.   push(@colr,$col eq "[16#00 16#00 16#00]"?0:$col);
  3756.   $temp=$arr{'margin-top'}*$arr{'font-size'};
  3757.   $mi=$temp if($temp>$mi);
  3758.   $temp=$arr{'margin-bottom'}*$arr{'font-size'};
  3759.   $mi=$temp if($temp>$mi);
  3760. sub fs {
  3761.   $arr{'font-family'}='times' if($el ne 'p' && !$latin1 && !defined $arr{$_});
  3762.   for ("font-family","font-size") {
  3763.     $arr{$_}=$body{$_} if(!defined $arr{$_});
  3764.   ($font=$arr{'font-family'})=~s/\W/-/g;
  3765.   if(!$font_names{"\L$font"}) {$font=$fal{$font}};
  3766.   if(!$font_names{"\L$font"}) {
  3767.     &dbg("Unknown font: $arr{'font-family'}, using $deffnt{$_[0]}\n");
  3768.     $font=$deffnt{$_[0]};
  3769.   if(!defined $fontid{"\L$font"}) {
  3770.     $fontid{"\L$font"}=$nfont++;
  3771.     @names=split(/\s+/,$font_names{"\L$font"});
  3772.     for($#names+1..3) {push(@names,$names[0])};
  3773.     @docfonts=(@docfonts,@names);
  3774.   &getval($arr{"font-size"},2);
  3775.   for ('left','right','top','bottom') {
  3776.     $arr{"margin-$_"}=0 if(!defined $arr{"margin-$_"});
  3777.   for ($arr{"text-indent"},$arr{"margin-top"},$arr{"margin-bottom"},
  3778.        $arr{"margin-left"},$arr{"margin-right"}) {
  3779.     &getval($_,0);
  3780.   $styl=$arr{'font-style'}=~/^(i|o)/+2*($arr{'font-weight'}=~/^b/);
  3781.   $col=$arr{'color'}?&col2rgb($arr{'color'}):-1;
  3782. sub img {
  3783.   local($_,$red,$grn,$blu)=@_;
  3784.   local($beg,$end);
  3785.   ($red,$grn,$blu)=("FF","FF","FF") if(!$opt_U);
  3786.   while (/<(img|fig|hr|overlay|object)\s/i) {
  3787.     $imgcmd="\L$1";
  3788.     $beg=$`;
  3789.     $'=~/>/;
  3790.     $img=" $`";
  3791.     $end=$';
  3792.     $img=~s/\n/ /g;
  3793.     if($imgcmd ne "object" || $img=~/data\s*=\s*['"]?([\w\/\.:~%-]+\.$IM)/i
  3794.        || $img=~/type\s*=\s*['"]?(image\/|application\/postscript)/i){
  3795.     if($opt_T) {
  3796.       &getalt;
  3797.     } else {
  3798.       $al=0;
  3799.       $off="";
  3800.       ($align)=$img=~/align\s*=\s*['"]?(\w*)/i;
  3801.       if($align=~/^middle$/i) {$al=1};
  3802.       if($align=~/^top$/i) {$al=2};
  3803.       if($imgcmd eq "overlay") {
  3804.         $al=4;
  3805.         $xoff=0;
  3806.         $yoff=0;
  3807.         if($img=~/\s*x\s*=\s*['"]?(\d+)/i) {$xoff=$1};
  3808.         if($img=~/\s*y\s*=\s*['"]?(\d+)/i) {$yoff=$1};
  3809.         $off="$xoff $yoff ";
  3810.       }
  3811.       $url="";
  3812.       if($img=~/\s(src|data)\s*=\s*($S)/i) {($url)=$+=~/([^ \n]*)/};
  3813.       &dbg("Image: $url\n") if($opt_d && $url);
  3814.       $URL=$url;
  3815.       unless($url=~m|://|) {
  3816.         if($url=~m|^http:(.*)|) {$url=$1}
  3817.         if($url=~m|^/|) {$URL=$b1.$url} else {$URL=$b2.$url}
  3818.       }
  3819.       while($URL!~m|^\.\./| && $URL=~m|[^/]*/\.\./|) {$URL=$`.$'};
  3820.       $URL=~s|/\./|/|g;
  3821.       $text=$src{$URL}?$cmd{$URL.$red.$grn.$blu}:$cmd{$URL};
  3822.       if(!$text || $opt_U && $src{$URL} && !$cmd{$URL.$red.$grn.$blu}) {
  3823.         if(!$url || $failed{$url}) {
  3824.           &getalt;
  3825.         } else {
  3826.           &pictops;
  3827.           if($bm || $ps) {
  3828.             &dbg("Size: $xs*$ys\n") if($opt_d);
  3829.             $nimg++;
  3830.             push(@XS,$xs);
  3831.             push(@YS,$ys);
  3832.             if($bm) {
  3833.               $nm++;
  3834.               push(@DP,$dp);
  3835.               push(@BM,$bm);
  3836.               push(@WS,int(($xs-1)*$dp/8)+1);
  3837.               push(@FC,$fc);
  3838.               push(@IX,$nm);
  3839.               push(@IT,0);
  3840.             }
  3841.             if($ps) {
  3842.               $nps--;
  3843.               push(@IX,$nps);
  3844.               push(@IT,1);
  3845.               $nli=99999;
  3846.               $n=1;
  3847.               $npr=$ps=~s|(.*\n){$nli}|sprintf("$&} D\n/P$nimg\_%d {",$n++)|eg;
  3848.               if($npr) {
  3849.                 $proc=" (";
  3850.                 for $i (0..$npr) {
  3851.                   $proc.="P$nimg\_$i ";
  3852.                 }
  3853.                 $proc.=")";
  3854.                 $pv.="/P$nimg\_0 {$ps} D\n";
  3855.                 $eps{"P$nimg\_0"}=$ps;
  3856.               } else {
  3857.                 $proc=" (P$nimg)";
  3858.                 $pv.="/P$nimg {$ps} D\n";
  3859.                 $eps{"P$nimg"}=$ps;
  3860.               }
  3861.             }
  3862.             $text="$proc $nimg IM(";
  3863.             $cmd{$URL}=$text if(!$cmd{$URL});
  3864.             $cmd{$URL.$red.$grn.$blu}=$text if($src{$URL});
  3865.             $proc="";
  3866.             $end=$' if($imgcmd eq "object" && $end=~m|</object>|i);
  3867.           } else {
  3868.             &getalt;
  3869.             $failed{"$url"}=1;
  3870.           }
  3871.         }
  3872.       } elsif($imgcmd eq "object" && $end=~m|</object>|i) {
  3873.         $end=$';
  3874.       }
  3875.     }
  3876.     if($cmd{$URL}) {
  3877.       $text=")".$off.$al.$text;
  3878.       if($imgcmd eq "fig") {
  3879.         $end=~m|</fig>|i;
  3880.         $fig=$`;
  3881.         $end=$';
  3882.         $over="";
  3883.         while($fig=~/(<overlay$R)/ig) {$over.=$1};
  3884.         ($dum,$cap)=$fig=~m|<caption$R([\w\W]*)</caption>|i;
  3885.         ($dum,$cred)=$fig=~m|<credit$R([\w\W]*)</credit>|i;
  3886.         $text=")BN($text$over)BN($cap)BN($cred)BN(";
  3887.       }
  3888.     }
  3889.     }
  3890.     $_=$beg.$text.$end;
  3891.   s|<[hH][rR]$R|)2 1 1 HR(|g;
  3892.   $_[0]=$_;
  3893. sub getval{
  3894.   local($val,$unit)=$_[0]=~/$V\s*(\w*)/g;
  3895.   $val*=$cm{$unit} if($_[1]==1 && defined $cm{$unit});
  3896.   $val*=$pt{$unit} if($_[1]==2 && defined $pt{$unit});
  3897.   $_[0]=$val;
  3898. sub getconf {
  3899.   local($_)=@_;
  3900.   while(/\@import\s+(([\w.\/-]+)|"([^"]*)"|'([^']*)')\s*;/) {
  3901.     if(open(SS,$+) && !$read{$+}) {
  3902.       $conf=<SS>;
  3903.       $_=$`.$conf.$';
  3904.       print DBG "***** $+:\n$conf" if($opt_d);
  3905.       close SS;
  3906.       $read{$+}=1;
  3907.     } else {
  3908.       &dbg($read{$+}?"Infinite \@import loop: $+\n":"Error opening: $+\n");
  3909.       $_=$`.$';
  3910.     }
  3911.   @block=();
  3912.   while(&getblk($_)){};
  3913. sub getblk {
  3914.   local($_)=@_;
  3915.   local ($beg,$match,$end,$blk,$key,$val,$id,$temp);
  3916.   while(/^\s*\/\*/) {
  3917.     /\*\/|$/;
  3918.     $_=$';
  3919.   return 0 if !/\S/;
  3920.   /[\w,:.@\s-]+\{/;
  3921.   $_=$';
  3922.   ($id=$&)=~s/^\s*|\s*\{//g;
  3923.   $id=lc $id;
  3924.   push(@block,"\L$id");
  3925.   if($#block==1) {
  3926.     $valid{$id}=1 if(!$user);
  3927.     if($id eq "color") {$id="colour"};
  3928.     if(!$valid{$id}) {
  3929.       &dbg("Error in configuration file: unknown block name '$id'\n");
  3930.     }
  3931.   $blk="";
  3932.   W:while(/\s*(\/\*|[\w][\w-]*\s*:|[\w,:.\s-]+\{|\})\s*/) {
  3933.     $blk.=$1 if($1 ne "/*");
  3934.     $beg=$`;
  3935.     $match=$1;
  3936.     $end=$';
  3937.     S:{
  3938.       if($match=~/\{$/) {
  3939.         $temp=$match.$end;
  3940.         $blk.=&getblk($temp);
  3941.         $_=$temp;
  3942.         last S;
  3943.       }
  3944.       if($match=~/:$/) {
  3945.         ($key=$`)=~s/\s*$//;
  3946.         $end=~/([\w.\$-]+|"[^"]*"|'[^']*')\s*;?/;
  3947.         $blk.=$`.$&;
  3948.         $_=$';
  3949.         ($val=$1)=~s/^["']|["']$//g;
  3950.         $val=~s/'/\\'/g;
  3951.         $typ=1;
  3952.         $typ=2 if($val=~/^$V(cm|mm|in|pt|pc|em)$/);
  3953.         $typ=3 if($val=~/^$V$/);
  3954.         $typ=4 if($val=~/^-?\d+$/);
  3955.         $typ=5 if($val eq "0" || $val eq "1");
  3956.         if($block[0] eq '@html2ps') {
  3957.           if($#block==0) {
  3958.             if(!$user) {
  3959.               $valid{$key}=1;
  3960.               $type{$key}=$typ if(!defined $type{$key});
  3961.             }
  3962.             if($valid{$key}) {
  3963.               if($typ>=$type{$key}) {
  3964.                 $key=~s/-/_/g;
  3965.                 eval "\$$key='$val'" if($user || $val ne '');
  3966. #               print DBG "\$$key='$val'\n" if($opt_d && $user);
  3967.               } elsif($user) {
  3968.                 &dbg("Error in configuration file: bad value for $key: $val\n");
  3969.               }
  3970.             } else {
  3971.               &dbg("Error in configuration file: unknown key '$key'\n");
  3972.             }
  3973.           }
  3974.           if($#block==1) {
  3975.             if($id eq "option" && $optalias{$key}) {$key=$optalias{$key}};
  3976.             if(!$user) {
  3977.               $valid{"$id,$key"}=1;
  3978.               $type{"$id,$key"}=$typ if(!defined $type{"$id,$key"});
  3979.             }
  3980.             if($valid{"$id,$key"} || $extend{$id}) {
  3981.               if($typ>=$type{"$id,$key"} || $id eq "colour") {
  3982.                 eval "\$$id\{'$key'}='$val'" if($user || $val ne '');
  3983. #               print DBG "\$$id\{'$key'}='$val'\n" if($opt_d && $user);
  3984.               } elsif($user) {
  3985.                 &dbg("Error in configuration file: bad value for $key: $val\n");
  3986.               }
  3987.             } else {
  3988.               &dbg("Error in block '$id' in configuration file:"
  3989.                   ." unknown key '$key'\n");
  3990.             }
  3991.           }
  3992.           if($#block>1) {
  3993.             $temp="$block[$#block-1]_$key";
  3994.             $valid{$temp}=1 if(!$user);
  3995.             $parblk=$block[$#block-1];
  3996.             if($valid{$temp}) {
  3997.               eval "\$$parblk\_$key\{'$id'}='$val'";
  3998. #             print DBG "\$$parblk\_$key\{'$id'}='$val'\n" if($opt_d && $user);
  3999.             } elsif($valid{$parblk}) {
  4000.               &dbg("Error in block '$parblk' in configuration file:"
  4001.                   ." unknown key '$key'\n");
  4002.             }
  4003.           }
  4004.         } else {
  4005.           for $i (split(',\s*',$id)) {
  4006.             $i=~s/\./_/;
  4007.             $i=~s/:/__/;
  4008.             eval "\$$i\{'\L$key'}='\L$val'";
  4009. #           print DBG "\$$i\{'\L$key'}='\L$val'\n" if($opt_d && $user);
  4010.           }
  4011.         }
  4012.         last S;
  4013.       }
  4014.       if($match eq "/*") {
  4015.         /\*\/|$/;
  4016.         $_=$';
  4017.         last S;
  4018.       }
  4019.     last W;
  4020.     }
  4021.   pop(@block);
  4022.   $_[0]=$end;
  4023.   $blk;
  4024. sub prompt {
  4025.   local($/)="\n";
  4026.   &dbg($_[0]);
  4027.   chop($_[1]=<STDIN>);
  4028. sub dbg {
  4029.   print STDERR $_[0];
  4030.   print DBG $_[0];
  4031. sub hb {
  4032.   local($_)=@_;
  4033.   local($head,$body,$beg,$end,$match,$tag);
  4034. #If neither </HEAD> nor <BODY> can be found, find the separation point (messy).
  4035.   if(!/<(body|\/head)/i || $`=~/<plaintext|<xmp|<listing|<!--/i) {
  4036.     $head="";
  4037.     $int="";
  4038.     S1: while(/<(\/?\w+|!--|!|\?)/) {
  4039.       S2:{
  4040.         $beg=$`;
  4041.         $end=$';
  4042.         $match=$&;
  4043.         $tag=$1;
  4044.         if($tag eq "!--") {
  4045.           $int.=$`;
  4046.           &getcom;
  4047.           $int.=$com;
  4048.           $_=$rest;
  4049.           last S2;
  4050.         }
  4051.         if($tag=~/[!?]/) {
  4052.           $end=~/>/;
  4053.           $int.="$beg$match$`>";
  4054.           $_=$';
  4055.           last S2;
  4056.         }
  4057.         $tag=~s|/||;
  4058.         last S1 if(!$head{"\L$tag"});
  4059.         $end=~/$R/;
  4060.         $head.=$int.$beg.$match.$&;
  4061.         $int="";
  4062.         $_=$';
  4063.       }
  4064.     }
  4065.     $body=$int.$_;
  4066.   } else {
  4067.     $head=$`;
  4068.     $body=$&.$';
  4069.   $_[0]=$body;
  4070.   $_[1]=$head;
  4071. sub open {
  4072.   if($_[0]=~m|://|) {
  4073.     &geturl($_[0],$_[1]);
  4074.   } elsif(open(FILE,$_[0])) {
  4075.     $_[1]=<FILE>;
  4076.     close FILE;
  4077.   } else {
  4078.     0;
  4079.